note 88230 deleted from book.session by peehaa

From: Date: Thu, 15 Jun 2017 13:41:09 +0000
Subject: note 88230 deleted from book.session by peehaa
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-209140@lists.php.net to get a copy of this message
Note Submitter: Some Guy ---- Just some notes - it seems that php does the session writing after the script exits. For example, if you set a bunch of session variables and then run session_regenerate_id() - the session variables are never written to the old session. The new session id is generated when you ask it to be generated, but the session exists only in memory until after the script exits - when the session is written and any and all session variables are written to it. This caused me some confusion, as I'm running sessions in an sql database rather than flat file, trying to do any manipulation of the session database directly in a script where you have run session_regenerate_id() will fail for the new session ID because the insert hasn't been done yet, and setting any session variables will only be written to the new session, even if set before you regenerate the session ID. Also - if using a database for sessions, make sure to use mysql_real_escape_string() before saving any session variables.

« previous php.notes (#209140) next »