D
D
Dmitry2017-04-17 19:52:24
PHP
Dmitry, 2017-04-17 19:52:24

How to delete cookies when moving to the next page?

Hello, how can I delete cookies when going to the next page?
That is, we went to the site.ru/res?id=1 page and saved the page id (and redirected to the page that was saved in the cookie (in this case, the site.ru/res?id=1 page), that is, when you enter to the site.ru/res page redirects to site.ru/res?id=1)
If, for example, we want to go to the site.ru/res?id=2 page, then it redirects to the site.ru/res?id=1 page like this how she enrolled in cookies.
And you can do that, for example, I went to another page of the site and the cookies were updated with the next page: here is the code

$we = $_GET['page']; // равно 1

setcookie("s34", $we);

if ($_COOKIE["s34"]) {
  $cookiepage = $_COOKIE["s34"];
  header("Location: site.ru/res?id=$cookiepage");
}
<a href="site.ru/res?id=2"> Статья</a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2017-04-17
@rpsv

Instead of it is simpler to store it all in SESSION?
And better add what is the essence of the question: do you want to implement 'backUrl' ? Alternatively, you can use $_SERVER['HTTP_REFERER']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question