Nick Li
Nick Li

Reputation: 312

How to clear session cookie ONLY on chrome development tools

For development/debug purpose, instead of disable chrome from reopening tab of previous session (and therefore retained session cookie), close chrome and reopen, or manually look for that session cookie in dev tool and delete it. I want to be able to delete session cookies ONLY on chrome without deleting other cookies (preferentially only the session cookie for site in current tab), technically simulate the browser has closed and reopen to the same page again.

is such function exist in dev tool or extension to do just that?

Upvotes: 1

Views: 4964

Answers (1)

Nadav
Nadav

Reputation: 1145

Since you need this clearing method specifically for one browser may I suggest the use of a bookmark script?

I wrote this little script that will prompt you for the cookie's name and then delete it. Create a new bookmark in Chrome and add the code below as the URL:

javascript:(function(){var cName=prompt("Enter the name of the cookie to delete.");if( typeof(cName) == 'undefined' ) return; document.cookie = cName +"=;domain="+ (document.location.host).replace('http://', '').replace('www','') + ";path=/;expires=Thu, 01 Jan 2001 00:00:00 GMT";})()

Do note that while the script works immediately upon clicking it, if the cookies tab was your active console tab while running the script you will need to switch to another tab and return to the cookies tab to see the visual representation of the cookie being deleted.

If you intend to use this script to delete one specific cookie in one specific environment you can hard-code the cookie name and location, thus minimizing the required code even further and removing the user interaction element. And as an added bonus if you have a Google account this bookmark will carry over to any device you have that is connected to it.

Upvotes: 1

Related Questions