How to make a cookie last only one request after being created in php [closed]

1

Good afternoon, my question is how can I make a cookie last for only one request in php

    
asked by anonymous 16.03.2017 / 17:33

1 answer

4

On the error display page, you only have to display cookie and delete it shortly after:

<?php
  if (isset($_COOKIE["message"]))
  {
    echo $_COOKIE["message"];
    unset($_COOKIE["message"]);
    // ^-- Aqui você exclui o cookie após a primeira requisição.
  }
?>
  

Remember to set an expiration time of cookie enough for the next request to be made, but not so large that if the window is closed before the second request is completed, display the error message when the user returns the page.

    
16.03.2017 / 17:57