Answer the question
In order to leave comments, you need to log in
Removing cookies in php?
Guys, good cool day!
In general, there is an authorization page /login
. You can go to it by clicking on the link in the header from any page of the site.
After authorization of the user, you need to redirect to the previous page (the one from which you went).
To do this, I create cookies at the very beginning of the file.
<?
if (!isset($_COOKIE['prev_addr'])){
setcookie("prev_addr",$_SERVER["HTTP_REFERER"],time()+3600,"/");
}
?>
<?
global $USER;
if ($USER->IsAuthorized()) {
$temp = $_COOKIE['prev_addr'];
setcookie("prev_addr","",time()-10000);
LocalRedirect($temp);
}
?>
Answer the question
In order to leave comments, you need to log in
In general, it can be useful to someone.
Weird. Did it before - didn't work. Thanks guys ;)
if (!isset($_COOKIE['prev_addr'])){
setcookie("prev_addr",$_SERVER["HTTP_REFERER"],time()+3600,"/");
}
global $USER;
if ($USER->IsAuthorized()) {
$temp = $_COOKIE['prev_addr'];
setcookie("prev_addr","",time()-3600,"/");
//unset($_COOKIE['prev_addr']);
LocalRedirect($temp);
}
And even better, as you set the cookie, delete it, only with a minus sign:setcookie("prev_addr","",time()-3600,"/");
When deleting, you also need to specify the path setcookie("prev_addr","",time()-10000, '/');
Check.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question