/**
* php 解密session字符串(官方写法)
* @param string $session_string session字符串
* @return array
*/
public function decodeSession(string $session_string)
{
$current_session = session_encode();
foreach ($_SESSION as $key => $value) {
unset($_SESSION[$key]);
}
session_decode($session_string);
$restored_session = $_SESSION;
foreach ($_SESSION as $key => $value) {
unset($_SESSION[$key]);
}
session_decode($current_session);
return $restored_session;
}
public function test()
{
session_start();
$str = 'session字符串';
$res = $this->decode_session($str);
print_r($res);
die;
}