Codeigniter用户数据不可用 [英] Codeigniter userdata not avaliable
问题描述
我为我的项目使用CodeIgniter。我接近结束,我现在不能改变会话引擎。我有在网址上发表评论的captcha图片:
I'm using CodeIgniter for my project. I'm near end and I cannot change session "engine" now. I have captcha image for comment posting on url:
example.com/captcha
和代码:
this->load->library('session');
header("Content-type: image/jpeg");
/*
* Image generation code...
*/
$this->session->set_userdata('captcha', strtolower($word));
imagejpeg($image);
imagedestroy($image);
通常当我提交表单时,我使用
Usually when I'm submitting a form I use
<img src="example.com/captcha" />
来生成图像并设置userdata。但这一次它不工作。 $ this-> session-> userdata('captcha')为空。
to generate image and set userdata. But this time it doesn't work. $this->session->userdata('captcha') is empty.
但是如果我直接访问图像sessiondata设置,下一次提交有一个$ word是在直接访问图像/验证码时生成的。
But if I visit image directly sessiondata is set and on next submit there is a $word which was generated on direct access of image/captcha. What could cause this?
推荐答案
图片在域名前加上www前缀,而索引在domain.com上。我通过设置会话的数据库来了解这一点。我看到有两个条目为一个页面访问具有不同的session_id。
The image was on domain with "www" prefix, while index was on domain.com. I figure this out by setting database for sessions. I've seen there were two entries for one page visit with different session_id.
这篇关于Codeigniter用户数据不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!