Jump to content

cross subdomain session


astralaaron

Recommended Posts

hi I have this working but I am still a little bit confused about if I am doing it right or not. I need my sessions to pass between subdomains on my website, so I have replaced

session_start();

with

session_name("crossSubSession");session_set_cookie_params(0, '/', '.mysite.com');session_start();

Works like a charm, my confusion is...with the session_name(); if I just leave it like that, will everyone who hits the page load the same session? Do I need to create a dynamic session_name for each person who logs in and then pass it around?

Link to comment
Share on other sites

I read in a post that I found on google that session_set_cookie_params(); wont work unless you set a session_name() first. I actually did not even think to try without session_name() until you said that, I thought it was going to work too but no, just like they said on that other forum it did not work when I took out session_name('something');

Link to comment
Share on other sites

The session name is not what distinguishes individual users, the session ID is. The name is the name of the ID value. By default you would get a cookie that looks like this: PHPSESSID=xxx If you change it then the cookie looks like this: crossSubSession=xxx The "xxx" part distinguishes individual users, they all have the same name regardless of whether you change it. You would only really need to change it if you want to have multiple different sessions for different applications on the same server, where you give each application a different session name so that you can keep track of the individual application sessions.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...