Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to: persistent PHP session across subdomains [duplicate]

Possible Duplicate:
PHP: Cookie domain / subdomain control
Allow php sessions to carry over to subdomains

Important Info

  • The website consists of hundreds of subdomains "example.domain.com"
  • Users logging into my site have the "remember me" feature
  • Users can login from any subdomain (and they must be able to navigate through any subdomain with that session)

Problem

  • Currently, when a user connects through one subdomain, their session/cookie (whether they chose the cookie option) isn't recognized on other subdomains.

Question

  • What must be done for a user session to be persistent across all subdomains of domain.com? In other words, I don't want a user to have to login on each subdomain.
like image 597
Adam Strudwick Avatar asked Dec 29 '12 04:12

Adam Strudwick


1 Answers

change the php.ini:

session.cookie_domain = domain.com

then it would be valid for all subdomains. But this depends on the all sub domais are providet by the same server.

If it are multiply servers then you have to share the session folder by NFS. Or you only add another cookie for auto login and have a seperate session for each subdomain.

http://en.php.net/manual/en/function.setcookie.php#domain

But the securrety in mind by your auto login cookie.

like image 168
GreenRover Avatar answered Nov 15 '22 17:11

GreenRover