Jump to content

Weird session_name() Behavior


Laxidasical

Recommended Posts

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???

Link to comment
Share on other sites

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?!?!?!?

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.