douhuai2015 2014-05-04 19:59
浏览 81
已采纳

使用PHP session_decode()而不将会话变量添加到自己的会话

I have a PHP script that uses session_decode to get the session variables of customer's session (from session stored file). The problem is that whenever I call the script and it reads the session variables, it also add them to my own session. Is there a way to avoid this or maybe use a better method to get the customer's session information without using session_decode?

Thanks

  • 写回答

1条回答 默认 最新

  • duanan2732 2014-05-05 15:39
    关注

    I think I have found the simplest solution/workaround:

    <?php
    // if session is not started
    session_start();
    
    // store our current session
    $my_sess = $_SESSION;
    
    // decode $data (the encoded session data, either from a file or database). Remember, decoded data is put directly into $_SESSION
    session_decode($data);
    $data = $_SESSION;
    
    print_r($data);
    
    // restore our own session
    $_SESSION = $my_sess;
    
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突