Welcome Guest, Not a member yet? Register   Sign In
Session data lost when database setting is enabled
#1

[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?
#2

[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?
#3

[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.




Theme © iAndrew 2016 - Forum software by © MyBB