0

Possible Duplicate:
PHP Sessions across sub domains

I can't seem to get this to work. I want to be able to log in from my main domain, and remain logged in when they go to a subdomain of the site. Whenever I go from my main domain to a subdomain, I'm immediately logged out.

I've tried changing session.cookie_domain in php.ini with no avail, as well as trying

ini_set('session.cookie_domain','.site.com' );

and this in .htaccess as well

php_value session.cookie_domain .site.com

How can I have sessions go between subdomains?

Community
  • 1
  • 1
Lucas Penney
  • 2,624
  • 4
  • 27
  • 36
  • 4
    Related threads : http://stackoverflow.com/questions/644920/allow-php-sessions-to-carry-over-to-subdomains and http://stackoverflow.com/questions/1064243/php-sessions-across-sub-domains – KV Prajapati Oct 04 '11 at 02:56

1 Answers1

0
  1. stick with ini_set(); or, even better, with session_set_cookie_params()

2. debug your code

  • verify your settings, if they actually were set, by outputting them
  • verify actual HTTP headers sent by your server to the client.
  • verify actual HTTP headers sent by your browser to the server.

Sessions are not a black box; it's just a combination of a few very simple mechanisms such as HTTP cookies, so check every part of it.

Nightfirecat
  • 11,432
  • 6
  • 35
  • 51
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345