CodeIgniter Forums

Full Version: Why does the session id keep changing?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum


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.


El Forum

[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?
$this->session->set_userdata('uid', $userid);

El Forum

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!


El Forum

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.