0

Possible Duplicate:
Allow php sessions to carry over to subdomains

How to setup user php $_SESSION to work in all subdomains? Like Google makes it.

Community
  • 1
  • 1
treng
  • 1,665
  • 3
  • 15
  • 22

2 Answers2

2

Have a look at session_set_cookie_params() to find out how to make your session cookie accessible to your domain

rodneyrehm
  • 13,442
  • 1
  • 40
  • 56
1

There are several things to take in account while sharing $_SESSION across subdomains.

  1. Are all subdomains on ran by the same server?

    1. If not, then, you will need to share sessions amongst servers, there are several solutions:

      • Use NFS (not recommended)
      • Move SESSION to another storage (Database, Memcache, Redis) (best option imho)
    2. If they are, you may just need to configure your cookie domain using session.cookie_domain ini directive.

  2. Are you running Suhosin, if you do, you may need to disable some security options to allow your session to be decrypted on the others servers.

Boris Guéry
  • 47,316
  • 8
  • 52
  • 87
  • 1
    Take at the [php manual](http://fr.php.net/manual/en/session.configuration.php#ini.session.cookie-domain) to know how to set such directive – Boris Guéry Jun 18 '12 at 16:05