Welcome Guest, Not a member yet? Register   Sign In
SOLVED Problem with sessions stored in databases
#1

[eluser]ipsod[/eluser]
When I don't use databases, my session variables work fine. When I do, I get no errors, but sessions do not work whatsoever.

I don't see where there's room for error on my end, it's just 2 steps - running a copy/pasted sql command and modifying a single variable in the config file - right?.

Here's my session config info:

Code:
$config['sess_cookie_name']        = 'ci_session';
$config['sess_expiration']        = 7200;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']        = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 300;

Here's the code I'm using to test (I comment out the set_userdata after running the script once to set it):
Code:
//$this->session->set_userdata('test', 'this');
echo $this->session->userdata('test');

*edit*
Tracked it down to using Doctrine for my models. Disabled Doctrine's hooks and it worked fine.

That's too bad. I think this is outside of my ability to fix, and I'll have to scrap Doctrine.
#2

[eluser]Narkboy[/eluser]
Ok first - sessions DO work with database storage, so it's not an inherant bug on CI's side - it must be something in either your sql, your code or your config.

If you're not getting any errors, check your log_threshold in config and error_reporting inm index.php. You'll need a log level of at least 1 and set error_reporting to E_ALL. This will ensure anything that goes wrong gets displayed or logged. Load up some pages then check the logs if no errors appear.

I'm assuming that you are already using databases for other things without any problems?

Let us know what the log / errors show.

/B
#3

[eluser]ipsod[/eluser]
n/m
#4

[eluser]ipsod[/eluser]
Thanks Nark
Ugh. Problem solved.

I was destroying the session every time, then setting session variables after that. It worked fine without databases, but not with them. It still doesn't make sense to me, because I was setting new session data after I destroyed the old one, but it wouldn't stick.

What a frustrating waste of time. I hate debugging.




Theme © iAndrew 2016 - Forum software by © MyBB