7

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.
4
  • 2
    Look here and here Commented Dec 29, 2012 at 4:17
  • @Nile I had already tried them, and all those solutions don't work for me. As for the htaccess solution, I even get a 505 error from the server. Commented Dec 29, 2012 at 4:30
  • For the not-working solutions: check with Wireshark what actually gets sent over the network. Also, check ALL session_ functions in the code and ALL ini_set calls in the code if they override the cookie-domain. Commented Dec 29, 2012 at 4:36
  • Have you tried setting the session_name before session_set_cookie_params? I had that issue way back. You should also use these functions before starting the session. Commented Dec 29, 2012 at 4:48

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.