Q: How do I use Fiddler to delete a single cookie?

2,045 views
Skip to first unread message

EricLaw

unread,
Apr 14, 2011, 10:10:17 AM4/14/11
to Fiddler
Q: Does anyone know how to use fiddler to delete a specific cookie
(e.g. not send it with the GET request)? I can see how to delete all
of them (oSession.oRequest.headers.Remove("Cookie");) but I can’t
figure out how to delete cookie foo.

A: Because of their awkward formatting as strings, there’s no direct
Fiddler feature to do this.

You can, however, use FiddlerScript to manipulate the cookie string;
click Rules > Customize Rules. Scroll down to OnBeforeRequest, and
modify the cookie string. It’s simplest to just rename the cookie in
question, although you could actually parse the string and remove the
name/value pairs (which potentially contain nested pairs) completely.

static function OnBeforeRequest(oSession: Session)
{
if (oSession.HostnameIs('www.example.com') &&
oSession.uriContains('pagewithCookie') &&
oSession.oRequest.headers.Contains("Cookie"))
{

var sCookie = oSession.oRequest["Cookie"];

// manipulate string here using RegEx or character replacement…
sCookie = sCookie.Replace("cookieName=", "ignoreme=");

oSession.oRequest["Cookie"] = sCookie;
}
Reply all
Reply to author
Forward
0 new messages