Welcome Guest, Not a member yet? Register   Sign In
CI Sessions not deleting?
#1

[eluser]Zero-10[/eluser]
I'm starting a new pet project for the fun of it and this time I'm not going to use phpBB to manage users, sessions etc... and I have found myself in a tight spot. You see, if I logout, it will call this function...

Code:
function logout()
    {
            $this->session->sess_destroy();
            redirect('http://localhost/');
    }

It logs me out fine, but when I log back in as a different person, my other username is still there and then I refresh and it'll be replaced with the new logged in one. If I access that section that should normally be restricted, it will work until i refresh if I'm not logged in.

I checked the database and it creates and deletes sessions just fine. Could it be that the cookie stored on my computer has a problem with it? If so, what can I do to make it expire when I logout?

Thank you!
#2

[eluser]4ever[/eluser]
I am just learning this step. See this tut starting at time 0:49:39
http://net.tutsplus.com/articles/news/co...y-6-login/
#3

[eluser]Zero-10[/eluser]
Thanks for the reply but netuts won't be helpful to resolute my problem, in fact a lot of the code in the video is for understanding how things work and not for practical use. I could in theory do something ugly and that's to create a variable to refresh the current page once and then redirect to the login page before it loads the page but that would be ugly. Cursed cache Tongue
#4

[eluser]Gerep[/eluser]
Try to destroy the session when you load the login view or before you set the session with the user information.
#5

[eluser]InsiteFX[/eluser]
Code:
function logout()
{
    // you need to unset the session user_data item!
    $this->session->unset_userdata('some_name');
    // or unset an array!
    $array_items = array('username' => '', 'email' => '');
    $this->session->unset_userdata($array_items);

    // my way!
    This->session->user_data = array();

    $this->session->sess_destroy();
    redirect('http://localhost/');
}

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB