note 129147 added to function.session-regenerate-id

From: Date: Sun, 07 Jan 2024 18:47:20 +0000
Subject: note 129147 added to function.session-regenerate-id
Groups: php.notes 
Request: Send a blank email to php-notes+get-221101@lists.php.net to get a copy of this message
The code example provided of my_session_regenerate_id() DOES NOT work and DESTROYS all session variables. Plus the second ini_set gives an error. The code for regenerating (only that part, the rest seems fine) should simply be this: <?php function my_session_regenerate_id() { $new_session_id = session_create_id(); // backup session variables $keepSession = $_SESSION ; // add info for users with bad connection not receiving the new session id $_SESSION['new_session_id'] = $new_session_id; // Set destroy timestamp $_SESSION['destroyed'] = time(); // Write and close current session; session_commit() ; // Start session with new session ID ini_set('session.use_strict_mode', 0); session_id($new_session_id); session_start(); $_SESSION = $keepSession ; } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.134 (proxied: 2a01:e0a:a51:3460:9195:4075:b8fa:ddf3) ---- Manual Page -- https://php.net/manual/en/function.session-regenerate-id.php Edit -- https://main.php.net/note/edit/129147 Del: integrated -- https://main.php.net/note/delete/129147/integrated Del: useless -- https://main.php.net/note/delete/129147/useless Del: bad code -- https://main.php.net/note/delete/129147/bad+code Del: spam -- https://main.php.net/note/delete/129147/spam Del: non-english -- https://main.php.net/note/delete/129147/non-english Del: in docs -- https://main.php.net/note/delete/129147/in+docs Del: other reasons-- https://main.php.net/note/delete/129147 Reject -- https://main.php.net/note/reject/129147 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221101) next »