note 41365 deleted from function.session-set-save-handler by danbrown
| From: | danbrown@php.net | Date: | Sun, 23 Jan 2011 16:20:45 +0000 |
| Subject: | note 41365 deleted from function.session-set-save-handler by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-176052@lists.php.net to get a copy of this message | ||
Note Submitter: Monty
----
It's really important to apply addslashes() to the serialized values passed to your custom
session Write handler if you are using MySQL for storing sessions, even if you have magic_quotes
turned on. Otherwise, values stored in $_SESSION will not be saved with the actual session in MySQL,
or will be truncated.
<?
function sessWrite($key, $val) {
$val = addslashes($val);
// Now do your database insert here.
return TRUE;
}
?>
Without addslashes(), the above handler would simply not work, and you will get no error back from
PHP about it either.