session IDs and multiple domains on one site

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
Big Dog
Forum Newbie
Posts: 2
Joined: Tue Apr 20, 2004 11:36 am

session IDs and multiple domains on one site

Post by Big Dog »

I have one site which uses multiple domain names and multiple directories. When someone moves to a different dir and domain on the site they have to re-register because the session id is no longer available. If they move back to the previous domain, the old session variable is still active. The session ID seems to be tied to one domain (I believe) Is there a way to keep the same session ID over all directories and domains on the one site?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

you could use cookies as a go between for the domains
magicrobotmonkey
Forum Regular
Posts: 888
Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA

Post by magicrobotmonkey »

or hidden form fields
Big Dog
Forum Newbie
Posts: 2
Joined: Tue Apr 20, 2004 11:36 am

Easy solutions ...

Post by Big Dog »

I was hoping there was a setting in php.ini that I could change to relax the domain condition. I don't have access to my php.ini, so I can't experiment, whatever I tell the sysadmin I have to be pretty sure about.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Code: Select all

ini_set('session.cookie_domain', '.yourdomain.com');
Should make the session available to everything at yourdomain.com

e.g.
http://www.yourdomain.com
forums.yourdomain.com
shop.yourdomain.com
yourdomain.com
Post Reply