note 64563 deleted from function.setcookie by nlopess
| From: | nlopess@php.net | Date: | Tue, 18 Apr 2006 19:47:03 +0000 |
| Subject: | note 64563 deleted from function.setcookie by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-108432@lists.php.net to get a copy of this message | ||
Note Submitter: liores [at] gmail.com
----
I am learning php and am trying to make a simple login script. This is what I have so far. Note: I
put a thing to display the cookies on every option for testing purposes. I am having a ton of
problems and it doesnt seem like it is working at all. Please help
<?
$file = "loginscripttest"; //This is the name of the file
$password_def = "hello"; //This is the password
if ($cmd==login)
{
if($password==$password_def)
{
setcookie("lioretest", lit);
echo("You have successfully logged in!<br /> Click <a
href=\"?cmd=admin\">here</a> to go to administration area.<br>");
echo $_COOKIE["TestCookie"];
echo $HTTP_COOKIE_VARS["TestCookie"];
}
}
elseif ($cmd==admin && $_COOKIE["lioretest"] = "lit")
{
echo ("This is the admin center. Click <a href=\"?cmd=logout\">here</a>
to log out.<br>");
echo $_COOKIE["TestCookie"];
echo $HTTP_COOKIE_VARS["TestCookie"];
}
elseif ($cmd==logout)
{
setcookie ("lioretest", "", time() - 3600);
echo("You have successfully logged out! Click <a href=\"$file.php\">here to
log back in.<br>");
echo $_COOKIE["TestCookie"];
echo $HTTP_COOKIE_VARS["TestCookie"];
}
else
{
if ($_COOKIE["lioretest"] = "lit")
{
echo("Welcome, you are now logged in. Click <a
href=\"?cmd=admin\">here</a> to access admin area.<br>");
echo $_COOKIE["TestCookie"];
echo $HTTP_COOKIE_VARS["TestCookie"];
}
else
{
echo("Sorry, you either do not have permission to access this page or are not logged
in");
}
}
?>