Welcome to WebmasterWorld Guest from 54.196.244.186

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

logout script not working on localhost

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

New User

joined:July 30, 2012
posts:5
votes: 0


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
12:51 am on Aug 2, 2012 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10544
votes: 8


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/)
1:05 am on Aug 2, 2012 (gmt 0)

Moderator from GB 

WebmasterWorld Administrator brotherhood_of_lan is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 30, 2002
posts:4842
votes: 1


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.
12:56 pm on Aug 2, 2012 (gmt 0)

New User

joined:July 30, 2012
posts:5
votes: 0


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?