if((isset($_POST<"remember_me">))&&($_POST<"remember_me">==1)) setcookie("email", $username, time()+3600); setcookie("pass", $pass, time()+3600); Now, when I cliông chồng on logout links (logout.php)i did this:
I didn"t use destroy session because I don"t want khổng lồ destroy all sessions....now destroying a session is working fine... but when I try khổng lồ unmix cookies, the browsers (all browsers: explorer, chrome, firefox, mozilla) give me an error saying that the new cookies cant be setted...any help lớn unmix the above sầu cookies ?
either use the superglobal _COOKIE variable:
unset($_COOKIE<"mycookiename">);or Hotline setcookie() with only the cookies name
setcookie("mycookiename");To rephối your cookies at logout use:
setcookie("pass");setcookie("email");For you login check:
if( isset($_POST<"remember_me">) && $_POST<"remember_me">==1 &và $_COOKIE<"pass"> != NULL && $_COOKIE<"email"> != NULL &&)
Check in your browser for the directory where the cookie operates. And unmix it by specify the path the cookie have sầu. Like in the example if the cookie directory is /aforum/
setcookie ("email","",time()-1,"/aforum/","http:// yourtên miền.com");
Just set the value of cookie khổng lồ false in order khổng lồ unmix it,
setcookie("cookiename", false);That"s the easiest way khổng lồ vị it.
Bạn đang xem: How to create, access and delete cookies in php
To unphối cookies in PHP., simply phối their expiry time lớn a time in the past. For example:
$expire = time() - 300;setcookie("email", "", $expire);setcookie("pass", "", $expire);
You need lớn mix your expire time to the past, e.g.
setcookie("email", "", time()-3600);Also you should be using an Absolute URI for your header("Location:" ....).
In Chrome và IE8+ at least, the following will remove the cookie from the browser. It will not be reflected in the $_COOKIE array until the page is reloaded however.
you may be able to lớn leave sầu off a few parameters here, but the important thing is you are setting an empty string, và that removes the cookie from the browser.
Thanks for contributing an answer khổng lồ Staông chồng Overflow!Please be sure to answer the question. Provide details & chia sẻ your research!
But avoid …Asking for help, clarification, or responding to other answers.Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Post Your Answer Discard
Not the answer you're looking for? Browse other questions tagged php cookies or ask your own question.
site kiến thiết / biểu tượng logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2021.7.22.39816