note 25815 rejected from function.session-set-save-handler by victor
| From: | victor@php.net | Date: | Tue, 08 Oct 2002 17:48:54 +0000 |
| Subject: | note 25815 rejected from function.session-set-save-handler by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-37796@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.