/    Sign up×
Community /Pin to ProfileBookmark

Path vs. Domain

I am trying to use the following function to delete a cookie. However, I am unclear as to what would be the path and what would be the domain. Can someone give me an example?

/**
* Deletes the specified cookie.
*

* name name of the cookie
*
[path] path of the cookie (must be same as path used to create cookie)
* [domain] domain of the cookie (must be same as domain used to create cookie)
*
/
function deleteCookie(name, path, domain)
{
if (getCookie(name))
{
document.cookie = name + “=” +
((path) ? “; path=” + path : “”) +
((domain) ? “; domain=” + domain : “”) +
“; expires=Thu, 01-Jan-70 00:00:01 GMT”;
}
}

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterApr 15.2005 — They are optional. Unless you created your cookie including your a path and domain, you can totally ignore giving the function extra arguments.
<i>
</i>deleteCookie("blah", "http://www.blah.com/search/index.html", "www.blah.com")
deleteCookie("blah")

The two above codes will both delete the cookie.
Copy linkTweet thisAlerts:
@betheballauthorApr 15.2005 — Thanks again.
Copy linkTweet thisAlerts:
@UltimaterApr 15.2005 — no problem
×

Success!

Help @betheball 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 5.17,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...