Managing session variable with Virtual Hosts

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tonic889
Forum Newbie
Posts: 8
Joined: Fri Apr 16, 2004 9:07 pm

Managing session variable with Virtual Hosts

Post by tonic889 »

I am running Apache 1.3.27 to host "www.mydomain.com". I have "mydomain.com" configured as a ServerAlias. My problem is that when PHP tracks sessions using cookies, it treats them as separate domains. In other words, "www.mydomain.com" gets one PHP Session ID, and "mydomain.com" gets a separate one. Is there any way to configure PHP to use the same session ID for two domain names? (Or, if anyone knows of something in Apache that I should configure differently, let me know...)

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

use [php_man]session_set_cookie_params[/php_man]() to set the domain the cookie will use to: '.mydomain.com' ...... notice the dot in front.
Post Reply