本文介绍了代码信号器修改会话数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在会话中存储的数据如下:

I store few data in session as the following:

$session_data = array("uid" => "test user", "loged_in" => true);

$this->session->set_userdata($session_data);

要修改uid,我尝试了

To modify the "uid" I tried

$uid = array("uid" => "New user");
$this->session->set_userdata($uid);

它没有工作,所以我试过

It did not work so I tried

 $this->session->set_userdata("uid","New user");

它也没有工作。没有找到任何有用的东西在谷歌。请帮助我如何更改会话中的值?

It also did not work. Cant find any useful stuff on google. Please help how can I change values in the session??

推荐答案

加载会话库$ this-> load-> library('session');这可能是一个愚蠢的问题,但它不会伤害问。

Did you load your session library? $this->load->library('session'); It might be a dumb question but it does not hurt to ask.

如何设置您的加密密钥?我想您会看到

What about setting your encryption key? I imagine you would see an error message for that http://ellislab.com/codeigniter/user_guide/libraries/encryption.html

$session_data = array('uid' => 'test user', 'logged_in' => TRUE);
$this->session->set_userdata($session_data);

// modify session
$this->session->set_userdata('uid', 'New user');

这篇关于代码信号器修改会话数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 02:31