Welcome Guest, Not a member yet? Register   Sign In
Can't destroy session
#1

[eluser]steelaz[/eluser]
I simplified my logout function to:
Code:
function logout()
{
    $this->session->sess_destroy();
    log_message('error', 'mailcode: '. $this->session->userdata('mailcode'));
}

but I still get value from session in error log. Any suggestions how to troubleshoot this?
#2

[eluser]Pascal Kriete[/eluser]
sess_destroy changes the expiration time of the cookie to a negative time, so it disappears on the next refresh. Try reloading the page, you'll see it go away.
#3

[eluser]steelaz[/eluser]
Thanks, that did the trick
#4

[eluser]BD-CI-Programmer[/eluser]
I have same problem. I can not destroy session. Please help me..
#5

[eluser]Pascal Kriete[/eluser]
Nahid, did you try refreshing? Are you using the native CI session library?

If the answer to both is yes, could you post a reduced version of your code that reproduces the problem.
#6

[eluser]adamp1[/eluser]
Theres a simple fix to this,
Code:
$this->session->sess_destroy();
$this->session->sess_create();

It first resets the expire time, then creating a new session it overwrites the old one. So no need for a refresh.
#7

[eluser]Yunus Khan[/eluser]
Steelaz and Nahid please try with following code

Code:
unset($_SESSION['your session data']);
session_destroy();
redirect('as your required page', 'location');
#8

[eluser]webthink[/eluser]
Yunus, There's no indication that they're using native sessions.
#9

[eluser]Yunus Khan[/eluser]
Right. But steelaz wanted to know about this with logout function then I gave him this solution

Code:
function logout()
{
    unset($_SESSION['user_id']);
    unset($_SESSION['usertype']);
    session_destroy();
    redirect('admin', 'location');
}
#10

[eluser]webthink[/eluser]
I know but the code you provided will only work if he's using PHP's Native Sessions. There's no indication that he is. In fact there is every indication that he isn't.




Theme © iAndrew 2016 - Forum software by © MyBB