[eluser]Unknown[/eluser]
Hi,
hi, i have a configuration library which for every page checks if the user logged in, if logged in, is cookie set, if not set, is the user active for last (some) minutes.
check_login_session() /config/check_login_session
{
if($this->CI->login->is_logged_in())
{
if($session_life > $inactive)
{
$this->CI->session->set_flashdata('uri', 'user/login');
$this->CI->session->set_flashdata('message', 'your session has expired, please login again.');
redirect('user/logout');
}
}
}
I have a logout controller function user/logut
logout()
{
$uri = $this->session->flashdata('uri');
$message = $this->session->flashdata('message');
$this->login->logout(

// Library file
$this->session->keep_flashdata('message');
redirect($uri);
}
a login library handling login session creation & logout sesion destroy. In that,
Logout library function login/logut
logout()
{
$this->CI->session->sess_destroy();
}
1. when the user is inactive the control is given to user/logout function
2. and it takes 2 session messages 1. redirect url 2. message.
3. then it calls the login/logout library which destroys the current session.
4. and redirects to the uri sent via flashdata.
here when i use $this->session->keep_flashdata('message'); in user/logout to keep the redirect url, the session is not getting destroyed and when it goes to next page, check login session function is again triggering as the user is not logged out which resulting an infinite loop.
when i remove keep_flashdata message in the logout function of user controller. everything is working fine.