note 25815 added to function.session-set-save-handler
| From: | ahmed at googgun dot com | Date: | Mon, 07 Oct 2002 20:13:00 +0000 |
| Subject: | note 25815 added to function.session-set-save-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-37756@lists.php.net to get a copy of this message | ||
A quick note when trying to implement session handling over SQL databases.
When you try to do something like this:
$qry = "REPLACE INTO SITE_SESSIONS (SessionKey, SessionExpiry, SessionValue) VALUES
('$key', $expiry, '$value' );";
mysql_query($qry);
This may fail if $value has a malformed string. In my case, $value had a single quote which made the
write_session fail.
My suggestion (and my solution) for such an occurance is to simply base64_encode($value) before the
SQL constructing the SQL statement in the write_session handler, and of course, to
base64_decode($value) in the read_session handler.
Cheers,
Ahmed.
--
http://www.php.net/manual/en/function.session-set-save-handler.php
http://master.php.net/manage/user-notes.php?action=edit+25815
http://master.php.net/manage/user-notes.php?action=delete+25815
http://master.php.net/manage/user-notes.php?action=reject+25815