Page 1 of 1

Slow logout on different server

Posted: Mon Aug 04, 2008 2:00 pm
by Dynamis
So here is the situation. I am running a website on my local machine as well as a copy of the website on a server. Now on my local machine, logout is instantaneous pretty much. As for the server, it just depends on its mood I guess. Admins seem to log out instantly whereas users sometimes wait 30+ seconds. While waiting, I noticed if I hit f5, I'm still logged in, but if I click log out again after hitting f5, I log out nearly instantly. As for the server, nothing else on it lags, ever. Let me put in some of my code snippets and see if you see anything odd. Seems the code is simple and straight forward though. Not seeing the issue.

Link to logout page:

Code: Select all

 
<?php 
    if($_SESSION['logged_in']) 
        echo '<br><br>You are currently logged in [<a onClick="return confirmLogout()" href="logout.php">logout</a>]';
    else
        include("login.php");
 ?>
 
logout.php:

Code: Select all

 
<?php
    include("extras/session.php");
    $session->logout();
    header("Location: index.php");
?>
 
session function logout():

Code: Select all

 
function logout(){
    session_destroy();
}
 
Any help is appreciated.

Re: Slow logout on different server

Posted: Mon Aug 04, 2008 2:29 pm
by Dynamis
Well the fix was pretty stupid but it works, here is the original code:
Dynamis wrote: logout.php:

Code: Select all

 
<?php
    include("extras/session.php");
    $session->logout();
    header("Location: index.php");
?>
 
Here is the fixed code:

Code: Select all

 
<?php
    include("extras/session.php");
    $session->logout();
    header("Location: index.php");
?>
<html></html>
 
The weird part is, logout.php is an include in another file so in reality, once included the code would look something of this nature:

Code: Select all

 
<html>
<?php
    include("extras/session.php");
    $session->logout();
    header("Location: index.php");
?>
<html></html>
</html>
 
Weird, but it works....

Re: Slow logout on different server

Posted: Mon Aug 04, 2008 3:40 pm
by RobertGonzalez
Have you tried throwing an exit() call after the header?

Re: Slow logout on different server

Posted: Mon Aug 04, 2008 8:09 pm
by Dynamis
I'll try tomorrow and leave some feedback.