Differentiate the session timeout in the encoder

Is it possible to have two user data for different timeout / expiration times? Let them say that the first data "param_1" expired after 1 day, and "param_2" expired after a month. How to do this with the CI Session Library. Something like that

$this->session->set_userdata('param_1', 86400); // seconds in a day $this->session->set_userdata('param_2', 2592000); // seconds in a month 
+7
php codeigniter-3
source share
2 answers

This is possible through "Tempdata" :

 $this->session->tempdata($key, $value, $validForTime); 

However , one session should not last more than several hours, or maybe a day. If you want a variable to persist longer, sessions are an absolutely wrong tool to use.

+7
source share

This would only be possible if you set a cookie on a client in a different domain than the usual one, with a longer expiration date and confirming this instead of session data. More practical, using ajax.get on the page for a specific URL that validates both cookies without starting a session (since the session may already have expired).

+5
source share

All Articles