Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
Thread: Sessions Across Subdomains
06-17-2006, 07:18 AM #1
- Join Date
- Sep 2004
- Thanked 0 Times in 0 Posts
Sessions Across Subdomains
I've been racking my brain with this and searching all over the internets and haven't been able to find a solution that I've been able to make work. I'm using the awesome login script for evolt.org. Works really well. However I've set up a subdomain with mod_writes on my site. So users have addresses - like http://my.website.com/user
The script is using cookies and sessions and I need the sessions to carry across the the subdomains. However they are not and I can't get them to work. I've read up on several ways to fix the problem but none have worked. So I thought perhaps if I provided the script pieces here that maybe someone could help me.
In the constants.php file:
* Cookie Constants - these are the parameters
* to the setcookie function call, change them
* if necessary to fit your website. If you need
* help, visit www.php.net for more info.
define("COOKIE_EXPIRE", 60*60*24*100); //100 days by default
define("COOKIE_PATH", "/"); //Avaible in whole domain
Then in the session.php file it sets the cookie here:
* This is the cool part: the user has requested that we remember that
* he's logged in, so we set two cookies. One to hold his username,
* and one to hold his random value userid. It expires by the time
* specified in constants.php. Now, next time he comes to our site, we will
* log him in automatically, but only if he didn't log out before he left.
setcookie("cookname", $this->username, time()+COOKIE_EXPIRE, COOKIE_PATH);
setcookie("cookid", $this->userid, time()+COOKIE_EXPIRE, COOKIE_PATH);
/* Login completed successfully */
Any help on this matter is appreciated. I know there's a solution. SOMEWHERE!