Here's what we are using to unserialize the session.
<?php
function unserialize_session($val) {
$result = array();
// prefixing with semicolon to make it easier to write the regular expression
$val = ';' . $val;
// regularexpression to find the keys
$keyreg = '/;([^|{}"]+)\|/';
// find all keys
$matches = array();
preg_match_all($keyreg, $val, $matches);
// only go further if we found some keys
if (isset($matches[1])) {
$keys = $matches[1];
// find the values by splitting the input on the key regular expression
$values = preg_split($keyreg, $val);
// unshift the first value since it's always empty (due to our semicolon prefix)
if (count($values) > 1) {
array_shift($values);
}
// combine the $keys and $values
$result = array_combine($keys, $values);
}
return $result;
}
?>