1
Good afternoon guys, my doubt is how I can make a cookie to last only one request in php
1
Good afternoon guys, my doubt is how I can make a cookie to last only one request in php
4
On the error display page, you simply display the cookie
and delete it immediately 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 date of the
cookie
sufficient 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.
Browser other questions tagged php
You are not signed in. Login or sign up in order to post.
You can delete the
coockie
so use it on the first request, but what would be the purpose?– Woss
You clearly don’t know what a request means, if you did, it wouldn’t make sense to use Sesssions, let alone cookies. Try to explain to us what you intend to get as a final result, what you want to do and we show you the way.
– Clayderson Ferreira
I’m only using it to send an error or success message, I use the setcookie() and do a header() to where I was, and ask in one place to show the cookie msg, but wanted q it disappears when I made another request
– user61973
I think the idea of putting the error message in a really weird cookie... I understand the logic - using the header to redirect - but it still sounds like gambiarra. I advise to try not to do so, because the chance to give problem later is great.
– Daniel