note 111324 added to function.session-regenerate-id

From: Date: Thu, 07 Feb 2013 03:49:05 +0000
Subject: note 111324 added to function.session-regenerate-id
Groups: php.notes 
Request: Send a blank email to php-notes+get-193546@lists.php.net to get a copy of this message
A follow up to the note by primenetworkzx at gmail dot com. I had a similar problem, and I found that it was caused by a bug in my implementation of the save handler. My write method used an SQL statement like this: <?php "UPDATE sessions SET data={$quote_data} WHERE id={$quote_id}" ?> This fails when session_regenerate_id() has been called, because the record with the correct id hasn't been created yet! The write method needs to check if the record exists first and, if it doesn't, must create it. Here's how you can do it in MySQL: <?php "INSERT INTO sessions (id, data) VALUES ({$quote_id}, {$quote_data}) ON DUPLICATE KEY UPDATE data=VALUES(data)" ?> ---- Server IP: 69.147.83.199 Probable Submitter: 221.186.89.65 ---- Manual Page -- http://php.net/manual/en/function.session-regenerate-id.php Edit -- https://master.php.net/note/edit/111324 Del: integrated -- https://master.php.net/note/delete/111324/integrated Del: useless -- https://master.php.net/note/delete/111324/useless Del: bad code -- https://master.php.net/note/delete/111324/bad+code Del: spam -- https://master.php.net/note/delete/111324/spam Del: non-english -- https://master.php.net/note/delete/111324/non-english Del: in docs -- https://master.php.net/note/delete/111324/in+docs Del: other reasons-- https://master.php.net/note/delete/111324 Reject -- https://master.php.net/note/reject/111324 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#193546) next »