Home >Backend Development >PHP Tutorial >ci 3.0 session读取成功后出现错误?

ci 3.0 session读取成功后出现错误?

WBOY
WBOYOriginal
2016-06-06 20:13:331210browse

在注册页生成验证码图片,并且有以下方法存储session
$this->load->library('session');
$this->session->randcode=验证码;

然后提交表单到另一页,另一页面读取session用以下方式
$this->load->library('session');
echo $this->session->randcode;
$this->session->randcode 值是打印出来了,
但是后面提示以下错误
ci 3.0 session读取成功后出现错误?

config.php中session配置如下

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 50;//300
$config['sess_regenerate_destroy'] = FALSE;

请问如何处理,为什么?

回复内容:

在注册页生成验证码图片,并且有以下方法存储session
$this->load->library('session');
$this->session->randcode=验证码;

然后提交表单到另一页,另一页面读取session用以下方式
$this->load->library('session');
echo $this->session->randcode;
$this->session->randcode 值是打印出来了,
但是后面提示以下错误
ci 3.0 session读取成功后出现错误?

config.php中session配置如下

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 50;//300
$config['sess_regenerate_destroy'] = FALSE;

请问如何处理,为什么?

sess_save_path不存在

解决办法:
修改$config['sess_save_path'] = 'sessions';
$config['sess_save_path'] = FCPATH.'sessions/';

在根目录下新建sessions文件夹,*nix系统需要给写权限

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn