Hi all currently am working in chat functionality in my project.
大家好我现在正在我的项目中使用聊天功能。
When a user start his conversation an id will be saved in the session, the id will same throughout the chat id value stored in session gets disappear
当用户开始他的对话时,会在会话中保存一个id,整个会话中的id会相同,会话中存储的聊天ID值会消失
In the following code i have mentioned the issues
在下面的代码中我提到了这些问题
Initially there is no session value for id then it will enter into to the if condition and session value will be created for id during next loop it should not allow to the if condition but in my case its allowing its because the session value get disappear
最初没有id的会话值然后它将进入if条件,并且会在下一个循环期间为id创建会话值,它不应该允许if条件但在我的情况下它允许它因为会话值消失
extract($this->input->post());
$loc=get_location($this->session->userdata('ip_address'));
$this->session->set_userdata('chatusername',$username);
$this->session->set_userdata('chatemail',$email);
if($this->session->userdata('id')=='')
{
$messageid= sprintf("%06d", mt_rand(100000, 999999));
$this->session->set_userdata('id',$messageid);
}
$data['message_id']=$this->session->userdata('id');
$data['username']=$username;
$data['email']=$email;
$data['department_id']=$department_id;
$data['message']=$message;
$this->db->insert('message',$data);
help me to solve this issue am confused can't find the cause of the issue
帮我解决这个问题很困惑找不到问题的原因
1 个解决方案
#1
0
Please check this solution and mentioned comments in the same: http://blog.jonaszamora.es/en/codeigniter-fix-for-session-loss-caused-by-ajax/
请检查此解决方案并提及相同的评论:http://blog.jonaszamora.es/en/codeigniter-fix-for-session-loss-caused-by-ajax/
#1
0
Please check this solution and mentioned comments in the same: http://blog.jonaszamora.es/en/codeigniter-fix-for-session-loss-caused-by-ajax/
请检查此解决方案并提及相同的评论:http://blog.jonaszamora.es/en/codeigniter-fix-for-session-loss-caused-by-ajax/