note 107323 added to function.session-regenerate-id

From: Date: Tue, 31 Jan 2012 02:49:04 +0000
Subject: note 107323 added to function.session-regenerate-id
Groups: php.notes 
Request: Send a blank email to php-notes+get-185802@lists.php.net to get a copy of this message
session_regenerate_id sends a new cookie but doesn't overwrite the value stored in $_COOKIE. After calling session_destroy, the open session ID is discarded, so simply restarting the session with session_start (as done in Ben Johnson's code) will re-open the original, though now empty, session for the current request (subsequent requests will use the new session ID). Instead of session_destroy+session_start, use the $delete_old_session parameter to session_regenerate_id to delete the previous session data. <?php session_start(); /* Create a new session, deleting the previous session data. */ session_regenerate_id(TRUE); /* erase data carried over from previous session */ $_SESSION=array(); ?> To start a new session and leave the old untouched, simply leave out the argument to session_regenerate_id. ---- Server IP: 69.147.83.197 Probable Submitter: 174.30.41.50 ---- Manual Page -- http://www.php.net/manual/en/function.session-regenerate-id.php Edit -- https://master.php.net/note/edit/107323 Del: integrated -- https://master.php.net/note/delete/107323/integrated Del: useless -- https://master.php.net/note/delete/107323/useless Del: bad code -- https://master.php.net/note/delete/107323/bad+code Del: spam -- https://master.php.net/note/delete/107323/spam Del: non-english -- https://master.php.net/note/delete/107323/non-english Del: in docs -- https://master.php.net/note/delete/107323/in+docs Del: other reasons-- https://master.php.net/note/delete/107323 Reject -- https://master.php.net/note/reject/107323 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#185802) next »