note 111324 deleted from function.session-regenerate-id by danbrown
| From: | danbrown@php.net | Date: | Tue, 05 Mar 2013 16:12:26 +0000 |
| Subject: | note 111324 deleted from function.session-regenerate-id by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193931@lists.php.net to get a copy of this message | ||
Note Submitter: Peter McArthur
----
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)" ?>