Please Is there a way to clear a particular cookie with JavaScript and it is compatible with all browsers? I am using .NET to register the script during pre_load.
Asked
Active
Viewed 292 times
0
-
Are you talking about a cookie that was set by a page on _your_ site? – nnnnnn Apr 07 '14 at 13:01
-
Im referring to a cookie that is not set by my own site. I am trying to clear a cookie that is set by Salesforce called sid. its suppose to be the session id. – user3214892 Apr 08 '14 at 11:41
1 Answers
1
I believe this should suffice:
<script type="text/javascript">
function delete_cookie( name ) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
</script>

Basit
- 1,830
- 2
- 31
- 50
-
Will this be able to clear a cookie that has been set by a different site. ie. Salesforce. – user3214892 Apr 08 '14 at 11:42
-
For security reasons, you cannot delete the cookie of a specific domain if you aren't on that domain. This answer explains it in detail http://stackoverflow.com/a/17777005/1303004 – Basit Apr 08 '14 at 13:11