Jump to content

question about sessions?


cluce

Recommended Posts

can someone tell me what is the difference between these two codes??

 

//sets session to authenticate
$_SESSION['loggedin'] = "yes";
             $_SESSION['id'] = $username;
             $sess_id = session_id();
             session_write_close();

     

 

//sets session to authenticate
$_SESSION['loggedin'] = "yes";
             session_write_close();	

     I am using the second code and it works but it was reccomended use the first one.  I know it sets a session ID but what for? or why do I need to set a session ID?

 

Link to comment
Share on other sites

You don't need to use $sess_id = session_id();. Only if you want to use the session id in your script somewhere.

 

session_write_close(); is only needed if you are using a frameset. This function can increase page load time if you are using a frame set, as explain by the manual:

Session data is usually stored after your script terminated without the need to call session_write_close()' date=' but as session data is locked to prevent concurrent writes only one script may operate on a session at any time. When using framesets together with sessions you will experience the frames loading one by one due to this locking. You can reduce the time needed to load all the frames by ending the session as soon as all changes to session variables are done.[/quote']
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.