CodeIgniter Forums
Why does the session id keep changing? - 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: Why does the session id keep changing? (/showthread.php?tid=12251)



Why does the session id keep changing? - El Forum - 10-12-2008

[eluser]mvdg27[/eluser]
Hi,

I'm working with the session class, and I notice that the session id keeps changing. I'd actually prefer (or better I need) the session id to stay the same, once assigned. Can this behavior be changed?

Thanks is advance.

-Michiel


Why does the session id keep changing? - El Forum - 10-12-2008

[eluser]Pascal Kriete[/eluser]
How often it happens is dedicated by the 'sess_time_to_update' config value. The default is 300 seconds. Increasing that would work, but it's not a very safe practice.

Can you elaborate on the problem? What prevents you from setting your own persistent value?
Code:
$this->session->set_userdata('uid', $userid);



Why does the session id keep changing? - El Forum - 10-12-2008

[eluser]mvdg27[/eluser]
Hi Imparo,

hmm .. do I feel stupid now!! I was indeed using the session id as an identifier in my database for the user. But off course I can create a unique code myself. The thought just never crossed my mind :S

Anyway, this solves my problem completely!! Thanks a lot!

Michiel


Why does the session id keep changing? - El Forum - 10-12-2008

[eluser]ray73864[/eluser]
i am creating a shopping cart system and instead of using the session itself for storing the cart, i store it in the database, after realising that every 5mins the cart was disappearing for some reason, i now create a 'fancy_session_id' which is basically just an md5() of time()+time() 'md5(time()+time())' and use that for the cart, then when the user logs in, i assign the cart to their userid.