cluce Posted June 8, 2007 Share Posted June 8, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/54770-question-about-sessions/ Share on other sites More sharing options...
wildteen88 Posted June 8, 2007 Share Posted June 8, 2007 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'] Quote Link to comment https://forums.phpfreaks.com/topic/54770-question-about-sessions/#findComment-270937 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.