views:

3795

answers:

3

Hello Everyone,

I am testing a web app that writes cookies to subdomain.thisdomain.com and several subfolders within that. I'm looking for JavaScript that I can put into a bookmarklet that will delete all cookies under that subdomain, regardless of the folder in which they exist.

Any ideas?

+3  A: 

I would recommend Firecookie extension to Firebug.

Sergey Ilinsky
a bookmarklet will (hopefully) work across browsers
Alexander Gyoshev
+8  A: 

Derived from my answer here:

javascript:new function(){var c=document.cookie.split(";");for(var i=0;i<c.length;i++){var e=c[i].indexOf("=");var n=e>-1?c[i].substr(0,e):c[i];document.cookie=n+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT";}}()

Due to browser security issues, this will only work when executed while on a page that has access to all the cookies you want to delete.

Robert J. Walker
Is there a place to put the domain name in this JavaScript? I'd like to remove cookies within my own browser for a particular domain and all subdomains. Like "www.microsoft.com" would take anything that starts with "www.microsoft.com" and remove all cookies.
Caveatrob
Bookmarklets play inside the browser's security sandbox, so they're not allowed to edit cookies from a different domain.
Robert J. Walker
Okay. I didn't read that right. I figured anything running as a bookmarklet would have access to all browser settings.
Caveatrob
Used the JS in a page to remove all cookies for a site. Worked great. Thx!
WaldenL
A: 

Very good for create a cookieless subdomain (I mean very good to serve static resources according to Google guidelines: http://code.google.com/intl/fr/speed/page-speed/docs/caching.html)

Thomas Decaux