php cookie problem
Posted: Thu Oct 16, 2008 8:04 pm
I'm trying to deny access to a page based on whether or not the user has a valid authorization cookie, but it doesn't work?
The problem is that the page will display the content whether or not I have a "UserLever" cookie. Does any one have a suggestion as how I can prevent people from viewing a specific page based on a cookie. Basically My cookie just has a value of 0 for admin, 1 for registered users, and 3 for guests. Any help would be greatly appreciated.
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
if ($_COOKIE["UserLevel"] == 0 || $_COOKIE["UserLevel"] == 1) {
echo '
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<p>your in</p>
</body>
</html>
';
}
else { echo 'your cookie is messed up'; }
?>