首页 小组 问答 话题 好文 素材 用户 唠叨 我的社区

[分享]php 解密session字符串

风轻yLv.1种子选手
2024-09-11 14:25:23
0
42


/**
 * 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;
}
风轻y
风轻y

41 天前

签名 :   42       0
评论
站长交流