/    Sign up×
Community /Pin to ProfileBookmark

Deleting Cookies

Okay, this sounds like sort of a newbie-ish question, but guess who I am! Anywho, the answer is rather difficult to find (for me), but I would think it possible. Can PHP delete cookies? If you can create them, read them, set expiration dates, surely a php script could delete the cookies sent from its website? Basically I have an expiration set for a cookie, but to give the option of deleting this cookie before it expires. Or at the very leaste, set its value to null. I’m using PHP 4.3.6 if that matters any. Is this at all possible?

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@The_CheatJun 04.2004 — i think what you do is set the cookie again, but to a date that is in the past
Copy linkTweet thisAlerts:
@JonaJun 04.2004 — [i]Originally posted by The Cheat [/i]

[B]i think what you do is set the cookie again, but to a date that is in the past [/B][/QUOTE]


[font=arial]That's correct. Here's some code that I use for a logout function, if it helps you any, Bob.[/font]

[code=php]
if(isset($_COOKIE["cusername"])){
setcookie("cusername", $_COOKIE["cusername"], time()-3600);
}
if(isset($_SESSION["cusername"])) {
session_destroy();

} if(!isset($_COOKIE["cusername"]) and !isset($_SESSION["cusername"])) {
header("Location: index.php");
}
[/code]
Copy linkTweet thisAlerts:
@MstrBobauthorJun 04.2004 — Thank you guys, works like a charm!
×

Success!

Help @MstrBob spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...