0

I want to delete a existing cookie with this:

header2.php

<?php
if(isset($_POST['logout1']))
    {
        unset($_COOKIE['hr']);
        setcookie("hr", "", time() -3600);
        header("Location: ../index.php");
        return true;
    } ?>

but cookies cannot be deleted. So what's the problem?

here's my

hr.php

 <?php 
 include "header2.php";
 $auth = $_COOKIE['hr'];
 header ("Cache-Control:no-cache");
 if(!$auth == "ok") 
 {
 header ("Location: ../index.php");
 }
 ?>
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
 <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"    style="background-color: #228B22">
 <ul class="nav navbar-nav navbar-right">
 <li>
 <h4 style = "margin-top:18px; color:#fff;"> HR </h4>
 </li>
 <li>
 <button type="submit" name="logout1">logout</button>
 </li>
 </ul>
 </div>

1 Answers1

0

If it helps this is a copy from some of my code to delete a cookie

setcookie('hr', null, -1, '/');
Tim
  • 176
  • 1
  • 15