I making a website and in the login page,I wrote code so that user click to “save login button”,browser will create cookie[‘id’] .In index.php page,I use ajax get data from logout.php page(Put in subfolders) but don’t understand why can’t the logout page cancel cookie[‘id’] although I use echo $_COOKIE[‘id’] still see it value
Hope everybody help
Hi,
Show code that you use to delete cookie
what date in the past are you setting the expiry to in order to delete it?
As @felgall said, you must set the cookie again but with the expiration date in the past.
Example: time()-1
I did so.After this is my code :
if($_COOKIE[‘id’]){
setcookie(‘id’,‘’,time()-3600);
}
I don’t know what must I do ? Can you help me ???
How do you set the cookie the first time?
I write like this :
if(empty($__POST[‘save_login’])){
$_SESSION[‘id’]=$id;
}else{setcookie(‘id’,$id,time()+259200);}
This works for me:
setcookie('id', $id, time()-1);
You may also try
setcookie('id', $id, time()-1, '/');
Also, try another browser, maybe you have some extension that does something with your cookies.
Why still can’t I do that ?
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.