Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookies - reading, then redirecting

Status
Not open for further replies.

CherylD

Programmer
May 1, 2001
107
CA
Hi there. I have a website with cookies created when a user is logged on. Some pages should only be viewable to those logged in. Here's what I've got, but it's not working:

<?
if (isset ($cookie)) {
return false; //do nothign
}
else{
header(&quot;Location: /pleaselogin.htm&quot;);
}
?>

It always redirects....any ideas why it's not reading the cookie properly?
 
Have you verified that $cookie contains a value? ______________________________________________________________________
TANSTAAFL!
 
Could you also check the value instead of just seeing if a cookie exists?...

if ($HTTP_COOKIE_VARS['somethinginparticular']) {
//do stuff
} else {
print (&quot;You are not logged in or you are not logged in properly.\n&quot;);
}

 
Agree with Jimobla
Looks like your cookie has not expired

Set a value to the cookie and a diff value when they log out.

Or force an expiration of the cookie.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top