Welcome Guest, Not a member yet? Register   Sign In
Strange behaviour with session destroy
#1

[eluser]Unknown[/eluser]
What is wrong in this code?

The session variable "user" has the id of the user logged. It's set on login process.
Code:
$this->session->set_userdata("user",$user->id);
This code always (at least on my server -ubuntu server 11.10, php 5.3.6) show the error page and perform the session destroy (all in one) !!! I'm completly sure, why? could the function logout be called twice without I can't appreciate it?

Code:
function logout(){
if ( !$this->session->userdata("user"))
{
   $error = "User do logout without been logged [" . $_SERVER['REMOTE_ADDR'] ."]" ;
   log_message('error', $error);
   show_error($error);
}
else
{
    $this->session->sess_destroy();
}
}
If I comment $this->session->sess_destroy() it works, the session is not destroy and the error is not shown.

If I insert an sleep of 4 seconds before sess_destroy it also works..

I know I can simplify...
Code:
function logout()
{
    $this->session->sess_destroy();
}

but I'm interesting in knowing what is happening.

Thanks in advance




Theme © iAndrew 2016 - Forum software by © MyBB