【问题标题】:What is the best way to flush user session data?刷新用户会话数据的最佳方法是什么?
【发布时间】:2014-03-16 22:59:08
【问题描述】:

PHP / CodeIgniter

根据我在 CI 手册中看到的内容,要从会话中刷新用户数据,需要创建一个包含值的数组并调用 $this->session->unset_userdata('$array')

其实有两个问题:

  1. 难道没有更优雅的方式来“刷新所有内容”吗?
  2. 是否存在刷新会话 ID、用户代理等核心关键会话信息的风险?

{CLARIFICATION] 不想终止会话...只是做一些家务。

谢谢。

【问题讨论】:

    标签: php codeigniter session


    【解决方案1】:

    不确定是不是你的意思,但你可以试试:

    session_destroy();
    

    【讨论】:

    • 我更多地考虑了家务。我会更新问题
    【解决方案2】:

    您可以删除会话...取决于您希望用户有什么可能性

    http://ellislab.com/codeigniter/user-guide/libraries/sessions.html
    
    Destroying a Session
    
    To clear the current session:
    
    $this->session->sess_destroy();
    

    或通过取消设置特定变量

    This function can also be passed an associative array of items to unset.
    
    $array_items = array('username' => '', 'email' => '');
    
    $this->session->unset_userdata($array_items);
    

    我认为没有必要做家务,而只是在需要时更新会话......

    【讨论】:

    • 我更多地考虑了家务。我会更新问题
    猜你喜欢
    • 1970-01-01
    • 2018-10-09
    • 1970-01-01
    • 1970-01-01
    • 2019-12-16
    • 1970-01-01
    • 2021-12-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多