ci sessions user_data disappears |
[eluser]Miky llanderal[/eluser]
hello i have exactly the same issue than this guy problem codeigniter sessions the problem is i logged id succesfully but switching between controller functions and views the data of the session disappears this is my code inicio controller Code: <?php I have autoloaded session library, and i have this configuration: Code: $config['sess_cookie_name'] = 'key'; anyone knows why is it happening?
[eluser]WanWizard[/eluser]
Which browser? What is your cookie configuration? Have you checked your session table? Is the initial session record created? Do you get a second record when you request another page? Did the browser receive and store the session cookie? Is the time on your server and client correct?
[eluser]Miky llanderal[/eluser]
I'm using chrome and firefox in ubuntu 10/apache2 mysql etc. the cookie conf I've tried putting the cookie domain localhost because i'm developing in local enviroment but i dont find difference with this Code: $config['cookie_prefix'] = ""; yes I checked the session table Code: CREATE TABLE IF NOT EXISTS `vinculacion_new`.`session` ( charset =UTF-8 Unicode collation utf8_general_ci and yes the initial session record is created correctly with all the data, and when i request other page or controller or something the session changes and user_data get lost I'll show you the inserts statements: Code: INSERT INTO `session` (`id`, `ip_address`, `user_agent`, `last_activity`, `user_data`) VALUES Code: INSERT INTO `session` (`id`, `ip_address`, `user_agent`, `last_activity`, `user_data`) VALUES And yes I deleted the cookies for testing and yes my browsers receive and store the cookie the hour is ok. I've tried to find the error but i can't find it
[eluser]Miky llanderal[/eluser]
Other thing that I found is when I'm using my controller after be logged Code: $this->function(); Code: $this-> function1(); But if I'm in a view and I click and anchor link the session get lost....
[eluser]WanWizard[/eluser]
Your user_agent field is to small. CI 2.0.2 needs 120 characters. Your UA check probably fails after which the session is destroyed. And note that you can not use 'localhost' for the cookie_domain, it's not accepted by Chrome. Leaving it empty isn't a goiod idea either. Better extract the hostname from the URI and use that, of configure it manually (for localhost, use 127.0.0.1).
[eluser]Miky llanderal[/eluser]
I change the table field 'user_agent' to 120 caracters and I put cookie domain 127.0.0.1, but it still be the same, in other hand, I put the project in other server, no in localhost enviroment and the sessions including my small field work well :S, which would be the issue?
[eluser]Miky llanderal[/eluser]
i read more about this and i put http://127.0.0.1/ in cookie domain but still wrong, i think that my problem may be the cookie, maybe the session doesn't find the cookie and that is why it starts other session .... but i don know how to fix this, i dont know how to set a cookie correctly in localhost enviroment,
[eluser]Miky llanderal[/eluser]
Update! I've tracked the error and I found the cause, I was setting the last activity in the table sessions with a function date() not with strtime(now) for timestamp, I changed it and everything works well Thank's for your help, it really helped me
[eluser]WanWizard[/eluser]
What do you mean "I was setting"? last_activity is an internal variable, you don't have to (and should not) touch that. |
Welcome Guest, Not a member yet? Register Sign In |