php - How to pass SESSION variable to a page in the parent directory? -


on web site have several sub-domains. files create context given sub-domain stored in corresponding sub-directory.

sometimes need link files not belong sub-domain.

for example, on "subdomain1.mysite.org" have link "www.mysite.org/login.php". "login.php" stored in directory contains subdirectories corresponding sub-domains.

if make link "www.mysite.org/login.php" in way: href='../login.php', not work. because browser tries access "subdomain1.mysite.org/../login.php". solve problem make link in way: href='http://www.mysite.org/login.php' think in way cannot pass session variables new page (can case?).

so, problem cannot find way pass session variables page located in parent directory (or page located on domain). know how problem can solved?

added

as recommended, tired use session_set_cookie_params solve problem. still cannot manage desired result. in more details following:

i have in index.php file generates content subdomain1.mysite.org use following code:

session_set_cookie_params(24*60*60,'/','.mysite.org'); session_start(); $_session['page'] = $php_self; 

than later, in same file make link 1 of pages (i think problem can here). create link in following way:

href='http://www.mysite.org/login.php' 

in login.php file have following code:

session_set_cookie_params(24*60*60,'/','.mysite.org'); session_start(); print "a".$_session['page']."b"; 

as result there nothing between "a" , "b". so, still cannot pass session variables 1 page one. know doing wrong?

added 2 have problem solved if add following line: session_name("some_name");

before

session_set_cookie_params.

in php ini can set session domain ".mysite.org" should able share session between multiple domains. relevant variable is:

session.cookie_domain

you can set inside script session_set_cookie_params() function.

edit - should note works if subdomains on same server (which looks are).


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -