views:

2080

answers:

2

Hello I use php sessions (not cookies, except for session id cookie) for all user data, and when a user goes to their profile user.mydomain.com they are immediately "logged out" untill then remove the subdomain.

Is there a way to accept sessions from all domains as long as its *.mydomain.com

thanks!

+5  A: 

Here are 3 options.

Place this in your php.ini:

session.cookie_domain = ".example.com"

In your .htaccess:

php_value session.cookie_domain .example.com

As the first thing in your script:

ini_set('session.cookie_domain', '.example.com' );
CTT
Unfortunately all 3 failed to work, does there need to be a star * ?
Anthony
Very strange, I've used the those methods before and they work fine. Do you by chance have Suhosin installed, I remember there be a setting that needed to be changed to allow this? If you don't, can you post more info about your install (eg. apache, lighttpd, php version)?
CTT
A: 

Be sure to see this thread too, as it's related:

http://stackoverflow.com/questions/348282/php-cookie-domain-subdomain-control

Eli