CodeIgniter Forums
Session data lost when database setting is enabled - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Session data lost when database setting is enabled (/showthread.php?tid=59903)



Session data lost when database setting is enabled - El Forum - 12-07-2013

[eluser]f0rest[/eluser]
I have just started learning CI to create a website and default sessions worked without problems.

When I enable database support (in my config.php, following the guide) my sessions are stored in DB correctly and <?php print_r ($this->session->all_userdata()) ?> shows me all data I stored but just when the page is loaded at the first time.

If I just refresh or change the page, all my custom data is lost, I can only see
Code:
Array (
[session_id] => 6fe8325b7873279c2cbad2e24bd48893
[ip_address] => ::1
[user_agent] => Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36
[last_activity] => 1386408424 )

session_id is the same as before, but all my custom data are lost.

I tried all solutions found on google (cookie names, domain, etc) but none worded. Anyone can help me?


Session data lost when database setting is enabled - El Forum - 12-07-2013

[eluser]f0rest[/eluser]
I almost found the problem. When CI tries to unserialize data from DB, it fails cause it found a multybite string (I have a multibyte string saved in my session user data) cuse it cannot compute correctly the length of that string.

Any tip to solve this?


Session data lost when database setting is enabled - El Forum - 12-07-2013

[eluser]f0rest[/eluser]
Ok, solved. I don't know why, but my DB tables were not UTF 8 general ci. Switched charset and it works again.