Good afternoon, my question is how can I make a cookie last for only one request in php
Good afternoon, my question is how can I make a cookie last for only one request in php
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.