Forum Moderators: coopster

Message Too Old, No Replies

logout script not working on localhost

         

t1000mills

1:06 pm on Aug 1, 2012 (gmt 0)

10+ Year Member



I have a logout script like this:


<?php
require 'core.php';

$_SESSION = array();
if($_COOKIE[session_name()]) {
setcookie(session_name(), '', time()-42000, '/');
}
session_destroy();

if(isset($httpReferer)) {
header("Location: $httpReferer");
} else {
header("Location: http://domain.com/index.php");
}

?>


I'm not sure how good of a logout script this is but it works perfectly on my remote hosted server. However, it does not work on localhost. It Locates back to httpReferer but the user is still logged in. I'm using xampp. Any help with this or comments about how good, bad, or unnecessary the script is would be greatly appreciated. Thanks

phranque

12:51 am on Aug 2, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



have you checked to see what cookies are stored by your browser and what cookies are sent with the request?

do you get the same behavior in multiple browsers?

do you have the same problem using the loopback IP address?
(http://127.0.0.1/)

brotherhood of LAN

1:05 am on Aug 2, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Also check the actual time being set in the past (as it may be in the future)... this may be an issue if your localhost is in a different timezone to your remote server.

using a plugin like firebug of http live headers would help see what's going on.

t1000mills

12:56 pm on Aug 2, 2012 (gmt 0)

10+ Year Member



hi, thanks for your help. I figured out the issue is that i didn't have the correct absolute path to the logout page so when i linked there from localhost it didnt link. wierd i didnt get a page not found error, it just seemed to refresh the page. I installed firebug and http live headers, thanks for the advice. Would you also recommend phpfire?