Tom Gullen
Tom Gullen

Reputation: 61727

Determine if a website sets a cookie

Using HttpWebRequest, how can we determine if the requested URL is attempting to set a cookie?

Also, how can we determine if any child elements (for example Google Analytics/third party iFrames) are attempting to set cookies?

Upvotes: 0

Views: 173

Answers (2)

svick
svick

Reputation: 244797

You can get the cookies set by a response by looking at the aptly named Cookies property.

Upvotes: 1

joocer
joocer

Reputation: 1121

You want to read the HTTP headers to check for a Set-Cookie header. See http://en.wikipedia.org/wiki/HTTP_cookie#Setting_a_cookie.

This won't pick up any cookies being set via JS or anything else executed in the browser but if the server is setting a cookie this should pick it up.

Upvotes: 1

Related Questions