Question

I am bit confused how can read a cookies file. I have try on google but have no proper solution. I have read this file but not success. ckps_ws_weather_deg cent www.bbc.co.uk/ 1600 4154368256 30363239 2133877056 30289814 * this file is downloading bbc.co.uk server. thanks in advance.

snapshot is my cookies file......enter image description here

Was it helpful?

Solution

Here's a great overview of cookies in ASP.NET. But to more directly answer your question, cookies that you manage (e.g. that you create) are written like this:

Response.Cookies["myCookie"].Value = "Hello, World!";

and then subsequently read like this:

var myCookie = Request.Cookies["myCookie"];
// if myCookie == null it doesn't exist

and further, deleting a cookie is a variant of modifying them. It's a little weird, but to get the browser to delete it you need to set its expiration to something earlier than today:

Response.Cookies.Add(new HttpCookie("myCookie")
    {
        Expires = DateTime.Today.AddDays(-1)
    });

But, if you're needing to read third party cookies, and you're trying to do that via ASP.NET, you would need to perform a cross-site scripting attack. There is a reason this is considered bad practice. This can be done via JavaScript, but I am not inclined to provide any code to do so because of its ethics.

EDIT

The OP updated their question while I was answering, and I do still stand on the fact that the intent of reading third party cookies via a web application is fishy at best.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top