Jump to content

How to make delete cookies button ?


Max45

Recommended Posts

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 ??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.