。
ただし、相続人の配列にそれを回すために迅速な機能(それが過度にエレガントではないかもしれませんが、私は1杯のコーヒーをのみ持っていた):
$string = 'active|i:1487613760;user_username|s:20:"[email protected]";user_key|s:8:"a5186adc";authenticated|b:1;user_name|s:12:"victor";user_email|s:20:"[email protected]";remember|b:1;
';
$array = deserializeSessionString($string);
echo $array['user_key'];
// deserialize a session string into an array
function deserializeSessionString($string)
{
$output = [];
// separate the key-value pairs and iterate
foreach(explode(';', $string) as $p) {
// separate the identifier with the contents
$bits = explode('|', $p);
// conditionally store in the correct format.
if(isset($bits[1])) {
$test = explode(':', $bits[1]);
switch($test[0]) {
// int
case 'i':
$output[$bits[0]] = $test[1];
break;
case 's':
// string
// ignore test[1], we dont care about it
$output[$bits[0]] = $test[2];
break;
case 'b':
// boolean
$output[$bits[0]] = ($test[1] == 1 ? true : false);
break;
}
}
}
return $output;
}
、あなたは何にアクセスすることができるはずですどのようにあなたのセッションハンドラがそれをシリアル化され、
echo $array['user_key'];
heres an example
奇妙なシリアル化形式を思わ:ちょうどキーで必要がありますか? – DevDonkey