Welcome to WebmasterWorld Guest from 54.159.165.175

Forum Moderators: coopster & jatar k

Logout cookie issue thats getting on my nerves.

Can't seem to figure this out..

   
2:25 pm on May 26, 2009 (gmt 0)

5+ Year Member



When I logout I get the first if which says if the cookie was set then I logout. The problem is when I logout and press enter in the url bar with the logout url still in the bar I get the if where the cookie is still set.

The cookies are not set anymore and I should of got the if !isset. I can click enter a gazillion times with the logout url and it'll keep showing me my if isset not the if !isset.

When I open a new tab and try it again in the old tab it'll finally show the if !isset.

I do I get rid of that? Seems like some kind of browser cache. This only happens with IE and not FireFox.

The following is my logout.php


####################START#######################
<?php
if (isset($_COOKIE['id']) && isset($_COOKIE['idsession']) && isset($_COOKIE['ip'])){
include ('c/connect.php');
setcookie('id', '', time() -3600);
setcookie('idsession', '', time() -3600);
setcookie('ip', '', time() -3600);
include ('header.php');
include ('sideleft.php');
?>
<div id="maincolumn">
<div class="text">
You have successfully logged out of HappyProfile.com
<br />
Thanks for visiting and come back soon!
<br />
<a href="login.php" style="font-weight:bold;">Log Back In</a>
</div>
</div>
<?php
include ('footer.php');
}//End cooke is set
if (!isset($_COOKIE['id']) && !isset($_COOKIE['idsession']) && !isset($_COOKIE['ip'])){
include ('c/connect.php');
include ('header.php');
include ('sideleft.php');
?>
<div id="maincolumn">
<?php
require ("error.php");
?>
</div>
<?php
include ('footer.php');
}//End cookie is not set
?>
####################END#######################

[edited by: Walley at 2:27 pm (utc) on May 26, 2009]

4:52 pm on May 26, 2009 (gmt 0)

5+ Year Member



Rather than doing isset() alone, you should incorporate empty() to check if $_COOKIE['id'] contains any data. Your logout script seems to reassigns the $_COOKIE['id'] to an empty string - however the $_COOKIE['id'] element is never completely removed. Perhaps even try unset() the cookie as well.
1:12 am on May 27, 2009 (gmt 0)

5+ Year Member



unset does not work.
Tried something like this and it's still doing the same...

<?php
include ('c/connect.php');
if (!empty($_COOKIE['id']) && !empty($_COOKIE['idsession']) && !empty($_COOKIE['ip'])){
if (isset($_COOKIE['id']) && isset($_COOKIE['idsession']) && isset($_COOKIE['ip'])){
setcookie('id', '', time() -3600);
setcookie('idsession', '', time() -3600);
setcookie('ip', '', time() -3600);
include ('header.php');
include ('sideleft.php');
?>
<div id="maincolumn">
<div class="text">
You have successfully logged out of HappyProfile.com
<br />
Thanks for visiting and come back soon!
<br />
<a href="login.php" style="font-weight:bold;">Log Back In</a>
</div>
</div>
<?php
include ('footer.php');
}//End if isset
else {//Go to if !isset
include ('header.php');
include ('sideleft.php');
?>
<div id="maincolumn">
<div class="text">
You are already logged in.
<br />
<a href="user.php" style="font-weight:bold;">My Account</a>
</div>
</div>
<?php
include ('footer.php');
}//End go to if !isset
}//End if !empty cookie
else {//Go to error.php
?>
<div id="maincolumn">
<?php
include ('header.php');
include ('sideleft.php');
require ("error.php");
include ('footer.php');
?>
</div>
<?php
}//End else go to error.php
?>

[edited by: Walley at 1:41 am (utc) on May 27, 2009]

2:08 am on May 27, 2009 (gmt 0)

5+ Year Member



I think I fixed it...
Added this to the header:

<meta http-equiv="Pragma" content="no-cache" />
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month