Laxidasical Posted March 16, 2008 Share Posted March 16, 2008 To my understanding, session_name() either returns the current name of the session or changes the name of a session from the default "PHPSESSID" to whatever it is that you set. So session_name('this_session') should produce a cookie with "this_session" as the name of the session id. This IS happening for me, however PHP is also passing the default "PHPSESSID" along with a separate session id. I've destroyed the session and cookie numerous times to be sure nothing was somehow being passed from previous sessions. I'm storing the sessions in a database. A quick look shows that PHP is using the id associated with the session name that I set, so it's not affecting my scripts. Still, is this normal behavior or is something wrong??? Quote Link to comment https://forums.phpfreaks.com/topic/96377-weird-session_name-behavior/ Share on other sites More sharing options...
wildteen88 Posted March 16, 2008 Share Posted March 16, 2008 If you are using a custom session name, then you'll need to call session_name('your_sessions_name') before you call session_start() Quote Link to comment https://forums.phpfreaks.com/topic/96377-weird-session_name-behavior/#findComment-493336 Share on other sites More sharing options...
Laxidasical Posted March 16, 2008 Author Share Posted March 16, 2008 I did, and a session id is given along with the specified session name as expected. BUT...when I look in the cookie, the default "PHPSESSID" is ALSO set with a completely different session id!!! As stated above, PHP seems to give priority to the session id of the name I set, so there hasn't been any ill effects. I'm just trying to find out if this is normal or if there is an issue with PHP?!?!?!? Quote Link to comment https://forums.phpfreaks.com/topic/96377-weird-session_name-behavior/#findComment-493450 Share on other sites More sharing options...
BlueSkyIS Posted March 16, 2008 Share Posted March 16, 2008 my 2 cents: if it's not breaking anything, don't spend time worrying about it either way. Quote Link to comment https://forums.phpfreaks.com/topic/96377-weird-session_name-behavior/#findComment-493451 Share on other sites More sharing options...
redarrow Posted March 16, 2008 Share Posted March 16, 2008 yep i agree, if the session works dont trie to repair it <<<<<<<<<<<<,, wisdom words, or your be there for hours trust me.......... Quote Link to comment https://forums.phpfreaks.com/topic/96377-weird-session_name-behavior/#findComment-493454 Share on other sites More sharing options...
Laxidasical Posted March 16, 2008 Author Share Posted March 16, 2008 yep i agree, if the session works dont trie to repair it <<<<<<<<<<<<,, wisdom words, or your be there for hours trust me.......... LOL - I hear what you and BlueSkyIS are saying. For some reason it makes me just a little nervous having two session ids out there. Suppose a server or PHP upgrade is made to my host and it suddenly starts recognizing PHPSESSID as the default. I know, I'm probably being paranoid. I'm not going to fiddle with it until I learn some concrete info on how session_name() is suppose to act in this regard... Quote Link to comment https://forums.phpfreaks.com/topic/96377-weird-session_name-behavior/#findComment-493585 Share on other sites More sharing options...
PFMaBiSmAd Posted March 16, 2008 Share Posted March 16, 2008 If you have set the session cookie lifetime to be some positive value, it is likely that the PHPSESSID name is leftover from a previous session. Delete the whole cookie and try it to see if the PHPSESSID is recreated. It is also possible that you have a session start in some code without the session_name() function. Quote Link to comment https://forums.phpfreaks.com/topic/96377-weird-session_name-behavior/#findComment-493591 Share on other sites More sharing options...
Laxidasical Posted March 17, 2008 Author Share Posted March 17, 2008 Not sure why, but it suddenly started working correctly. ??? Before I started this thread I deleted both the session and cookie as well as rebooted several times (for something else). That was yesterday. About 15 minutes ago it started working...wierd! All's well that ends well... Quote Link to comment https://forums.phpfreaks.com/topic/96377-weird-session_name-behavior/#findComment-493869 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.