3

I'm developping this website where each subdomain is a service, I wanted the user accounts to work on ever subdomains and users not having to relog everytime they switch from a subdomain to another so I'm using this code:

session_name("login");
session_set_cookie_params(0, '/', '.my_domain.com');
session_start();

It works very well, now my problem is with the keep alive, since some subdomains host single page applications, I have to do ajax calls to keep the PHP session alive, instead of putting a keep_alive.php file per subdomains (which would be the exact same file) I'm trying to use a single keep_alive.php file on one subdomain and do all the ajax calls on this file.

The problem is it doesn't work when the call is made from a different subdomain.

Example:

My keep_alive.php file is hosted on static.my_domain.com

If I try to call it from pics.my_domain.com it says $_SESSION isn't set, but if I call it from static.my_domain.com it works.

My .htaccess file already accepts Access-Control-Allow-Origin from other subdomains. I'm kind of stuck.

It it possible or my only solution is to copy the keep_alive.php file for each subdomain / create a symlink?

Mokkun
  • 708
  • 4
  • 14
  • Show this question i think you help it. [Link](http://stackoverflow.com/questions/20091445/share-session-on-subdomains-in-php) – Suman Jul 16 '16 at 13:28

0 Answers0