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:
- site1.example.com
- 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
Post a Comment