Max45 Posted April 2, 2020 Share Posted April 2, 2020 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 ?? Quote Link to comment https://forums.phpfreaks.com/topic/310452-how-to-make-delete-cookies-button/ Share on other sites More sharing options...
requinix Posted April 2, 2020 Share Posted April 2, 2020 Check the documentation for setcookie(). 1 Quote Link to comment https://forums.phpfreaks.com/topic/310452-how-to-make-delete-cookies-button/#findComment-1576187 Share on other sites More sharing options...
ginerjm Posted April 3, 2020 Share Posted April 3, 2020 You should NOT EVER store any kind of hint to a password. Once the user has logged in with his/her password all you need is perhaps the username and a token (maybe). You never need the pswd again. 1 Quote Link to comment https://forums.phpfreaks.com/topic/310452-how-to-make-delete-cookies-button/#findComment-1576189 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.