note 24734 added to function.session-decode
| From: | frank1970_REMOVEME_ at web dot de | Date: | Tue, 27 Aug 2002 13:01:30 +0000 |
| Subject: | note 24734 added to function.session-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-35729@lists.php.net to get a copy of this message | ||
A small annotation to mark(at)tweakt.net's function:
Seems like the session vars are not always delimited by a ";". If the variable is an
array, the ";" is omitted in the session string and the variable-definition is delimited
by the closing "}".
so this gave me better results:
function sess_string_to_array($sd)
{
$sess_array = array();
$vars = preg_split('/[;}]/', $sd);
for ($i=0; $i < sizeof($vars); $i++)
{
$parts = explode('|', $vars[$i]);
$key = $parts[0];
$val = unserialize($parts[1].";");
$sess_array[$key] = $val;
}
return $sess_array;
}
--
http://www.php.net/manual/en/function.session-decode.php
http://master.php.net/manage/user-notes.php?action=edit+24734
http://master.php.net/manage/user-notes.php?action=delete+24734
http://master.php.net/manage/user-notes.php?action=reject+24734