note 103055 added to function.session-set-save-handler

From: Date: Tue, 22 Mar 2011 21:37:50 +0000
Subject: note 103055 added to function.session-set-save-handler
Groups: php.notes 
Request: Send a blank email to php-notes+get-178111@lists.php.net to get a copy of this message
I had trouble with committing session data. To "commit and continue" without closing your session, put this at the top of your "write" method: <?php $id = session_id(); session_write_close(); session_id($id); session_start(); ?> Note that ANY time php generates a new session id, it is not automatically updated in a database. This can be helpful: <?php public function resetSessionId() { $old = session_id(); session_regenerate_id(); $new = session_id(); SessionHandler::regenerate_id($old,$new); } public function regenerate_id($old,$new) { $db = mysqli->connect(...); $db->query('UPDATE sessions SET session_id = \''.$db->escape_string($new).'\' WHERE session_id = \''.$db->escape_string($old).'\''); } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 68.179.14.105 ---- Manual Page -- http://www.php.net/manual/en/function.session-set-save-handler.php Edit -- https://master.php.net/note/edit/103055 Del: integrated -- https://master.php.net/note/delete/103055/integrated Del: useless -- https://master.php.net/note/delete/103055/useless Del: bad code -- https://master.php.net/note/delete/103055/bad+code Del: spam -- https://master.php.net/note/delete/103055/spam Del: non-english -- https://master.php.net/note/delete/103055/non-english Del: in docs -- https://master.php.net/note/delete/103055/in+docs Del: other reasons-- https://master.php.net/note/delete/103055 Reject -- https://master.php.net/note/reject/103055 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178111) next »