PDA

View Full Version : sessions across sub domains?


bazz
05-09-2008, 07:58 PM
Just curious about whether a session can be maintained across different sub domains eg

http://stuff.example.com
http://morestuff.example.com

In my effort to use sessions throughout my bookings system, I am find that when moving across to the secure sub domain, the existingly stored session data seems to be gone, when in fact, it is a different session.

Not the end of the world if I can't do it but, I'd like to be sure of the answer so that I don't needlessly pass params from form to form, more than I need to.

bazz

derzok
05-13-2008, 04:12 PM
I think it has to do with how the http daemon is storing sessions. I believe that apache does it as you explained - so that each subdomain has its own sessions.

eak
05-13-2008, 04:37 PM
I have done this with php using session_set_cookie_params.
You should be able to do it in perl too.
You just have the change the domain on your session cookie to ".yourdomain.com"
The preceding dot is required.

bazz
05-13-2008, 08:43 PM
Thank you both. I feel enlightened now so I know what I should look for.

bazz