【问题标题】:What is the best way to flush user session data?刷新用户会话数据的最佳方法是什么?
【发布时间】:2014-03-16 22:59:08
【问题描述】:
PHP / CodeIgniter
根据我在 CI 手册中看到的内容,要从会话中刷新用户数据,需要创建一个包含值的数组并调用 $this->session->unset_userdata('$array')
其实有两个问题:
- 难道没有更优雅的方式来“刷新所有内容”吗?
- 是否存在刷新会话 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);
我认为没有必要做家务,而只是在需要时更新会话......