session - Sharing $_SESSION variables across subdomains using PHP -


i trying share contents of session variable across 2 subdomains reason not working.

the sessionid same on both subdomains variables aren't available.

i can achieve cookies , working rather use values in session.

here how i'm setting domain session:

thanks, scott

update sorry should have said, using following:

ini_set('session.cookie_domain', substr($_server['server_name'],strpos($_server['server_name'],"."),100));  if(session_id ==''){session_start();} 

you looking function: session_set_cookie_params(). have 2 domains:

  1. site1.example.com
  2. site2.example.com

in order share session data across both domains, call following functiontion before session_start():

session_set_cookie_params(0, '/', '.example.com');

(edit: indeed forgot dot in example code)


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -