Why, after creating a cookie, and if you click on the exit, the cookie is not deleted?

<?php error_reporting(-1); header('Content-Type: text/html; char set=utf-8'); ini_set('display_errors', 'On'); if(isset($_POST['login']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) && ($_POST['password'])){ setcookie($_POST['login'], $_POST['email'], time()+3600*24*30, '/'); echo 'Ваш Логин: ' . $_POST['login'] . '<br>'; echo 'Ваш Email: ' . $_POST['email'] . '<br>'; echo 'Ваш Пароль: ' . $_POST['password'] . '<br>'; echo ' <form action="" method="post"> <input type="submit" value="Выход" name="exit"> </form> '; if(isset($_POST['exit'])){ unset($_COOKIE[$_POST['login']]); } } ?> <div class="login" style="border: 1px solid; width: 220px; clear: both; overflow: hidden"> <p style="text-align: center;">Вход</p> <form action="" method="post"> <div style="clear: both;"> <span style="float: left">Логин:</span> <input type="text" name="login" style="float: right; width: 150px;"> </div> <div style="clear: both;"> <span style="float: left">Email:</span> <input type="text" name="email" style="float: right; width: 150px;"> </div> <div style="clear: both;"> <span style="float: left">Пароль:</span> <input type="text" name="password" style="float: right; width: 150px;"> </div> <div style="margin-top: 30px; overflow: hidden"> <input type="submit" value="Войти" style="float: right;"> </div> </form> </div> 

    1 answer 1

    Delete cookies by setting this negative time, an hour ago.

     setcookie("login", "", time() - 3600); 
    • did so, it still does not delete if (isset ($ _ POST ['exit'])) {setcookie ($ _ POST ['login'], "", time () - 3600); } - DivMan
    • make a print if you are there at all, `if (isset ($ _ POST ['exit'])) {print_r ($ _ POST)` - L. Vadim
    • such condition also does not work if (isset ($ _ POST ['exit']) && $ login == $ _POST ['login']) { - DivMan
    • then you are sending something wrong, type this print_r($_POST); at the beginning of the file print_r($_POST); and add what came to the question - L. Vadim