Hi
I have made this simple login page by setcookies function and I want now to make a logout button.
Here the code
<?php
/*
PHP Form Login Remember Functionality with Cookies
*/
if(!empty($_POST["remember"])) {
setcookie ("username",$_POST["username"],time()+ 3600);
setcookie ("password",$_POST["password"],time()+ 3600);
setcookie ("color",$_POST["color"],time()+ 3600);
//3600 = 1 hour
//86400 = 1 day
//(8640*30) = 1 month
echo "Cookies Set Successfuly";
} else {
setcookie("username","");
setcookie("password","");
setcookie("color","");
echo "Cookies Not Set";
}
?>
<form action="Cookies.php" method="post"
style="border: 2px dotted blue;
text-align:center; width: 400px;">
<p>Welcome <?php echo ( !empty($_POST ['username']) ) ?
$_POST ['username'] : 'USER'; ?>
</p>
<p>Username: <input name="username" type="text"
value="<?php if(isset($_COOKIE["username"]))
{ echo $_COOKIE["username"],( !empty($_POST ['username']) ) ?
$_POST ['username'] : '';} ?>" >
</p>
<p>Password: <input name="password" type="password" value="
<?php if(isset($_COOKIE["password"]))
{ echo $_COOKIE["password"]; } ?>" >
</p>
<p>Choose Your Favorite Color: <input name="color" type="color"
value="<?php if(isset($_COOKIE["color"]))
{ echo $_COOKIE["color"]; } ?>">
</p>
<p><input type="checkbox" name="remember" /> Remember me</p>
<p><input type="submit" value="Login"></p>
</form>
Any idea ??