Welcome Guest, Not a member yet? Register   Sign In
Trying to store session data then redirect - Failing to store session! (First post...)
#1

[eluser]Unknown[/eluser]
Something is strange here. I have a controller called "auth" that sets a variable to a session and redirects back to the home page:

Code:
$this->session->set_userdata('userid', $row['id']);

redirect('home', 'refresh');

Everything is working fine except for the session which does not get populated unless I add some random variables to my query string. What it looks like is the code is caching somehow and ignoring "set_userdata". If I play around with "shift-F5" I can get the session to set.

Anyone know why this is happening?

THANKS!!!
#2

[eluser]dcrawkstar[/eluser]
I dont know, but I was tired of messing with the codeignitor session lib so I wrote my own that keeps everything in a database, and does it clean.... Let me know if you'd rather use that... ill post the code
#3

[eluser]stuffradio[/eluser]
Sounds like you're doing it incorrectly.

What's your query code?

Should be something like:
Code:
$query = $this->db->get('table');
$row = $query->row();

$this->session->set_userdata('userid', $row->id);

redirect('home', 'refresh');

You still need to do a query to select where the username is in the db though.




Theme © iAndrew 2016 - Forum software by © MyBB