Codeigniter userdata not available

一个人想着一个人 提交于 2019-12-25 03:53:10

问题


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

and code:

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" />

to generate image and set userdata. But this time it doesn't work. $this->session->userdata('captcha') is empty.

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?


回答1:


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.



来源:https://stackoverflow.com/questions/10806228/codeigniter-userdata-not-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!