homepage Welcome to WebmasterWorld Guest from 54.235.36.164
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Logout cookie issue thats getting on my nerves.
Can't seem to figure this out..
Walley




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

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]

 

d40sithui




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

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.

Walley




msg:3920652
 1:12 am on May 27, 2009 (gmt 0)

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]

Walley




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

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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved