note 101427 added to function.session-decode

From: Date: Thu, 16 Dec 2010 09:18:18 +0000
Subject: note 101427 added to function.session-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-174970@lists.php.net to get a copy of this message
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; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 194.78.141.42 ---- Manual Page -- http://www.php.net/manual/en/function.session-decode.php Edit -- https://master.php.net/note/edit/101427 Del: integrated -- https://master.php.net/note/delete/101427/integrated Del: useless -- https://master.php.net/note/delete/101427/useless Del: bad code -- https://master.php.net/note/delete/101427/bad+code Del: spam -- https://master.php.net/note/delete/101427/spam Del: non-english -- https://master.php.net/note/delete/101427/non-english Del: in docs -- https://master.php.net/note/delete/101427/in+docs Del: other reasons-- https://master.php.net/note/delete/101427 Reject -- https://master.php.net/note/reject/101427 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174970) next »