Welcome Guest, Not a member yet? Register   Sign In
[CLOSED] Codeigniter Sessions Redirect If Expired
#3

[eluser]CroNiX[/eluser]
The easiest way to do this is to just set a session variable after they log in and then test for it.

After successful login:
Code:
$this->session->set_userdata('logged_in', TRUE);

If the session expires, or they log out (and you remove their session data when they do), this variable will no longer be set in session so you can test for it. If a session variable does NOT exist, the session class will return boolean FALSE.

Code:
if ($this->session->userdata('logged_in') === FALSE)
{
  redirect('login');
}


Messages In This Thread
[CLOSED] Codeigniter Sessions Redirect If Expired - by El Forum - 06-30-2014, 03:53 AM
[CLOSED] Codeigniter Sessions Redirect If Expired - by El Forum - 06-30-2014, 07:27 AM
[CLOSED] Codeigniter Sessions Redirect If Expired - by El Forum - 06-30-2014, 05:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB