Vladimir
Vladimir

Reputation: 447

How to clear cookies of HttpWebRequest in WP7?

My logout does not seem to work. I clear cookies like that:

foreach (Cookie cookie in _session.Cookie.GetCookies(new Uri(Session.ServerSecureURL + "/Login", UriKind.Absolute)))
            {
                cookie.Discard = true;
                cookie.Expired = true;
            }

But next time I try to login, I get the previous user's session, even though, I verified, and in the web request I see a new cookie.

Anyone had similar problems with cookies?

Upvotes: 0

Views: 651

Answers (2)

Vladimir
Vladimir

Reputation: 447

I Found the problem. It was not Cookie related after all. I used wireshark to see what is sent to the server, and found out that after i logout there is only one call to the server, the one that logs me back in, but no calls to retrieve the data are made. Apparently WP7 retrieves me the old data from previous session from cache. I fixed that by adding a random data to the end of my url, and now it works perfectly. I'm still wondering what is the right way to control caching on WP7.

Upvotes: 1

AnthonyWJones
AnthonyWJones

Reputation: 189535

This:-

new Uri(Session.ServerSecureURL + "/Login", UriKind.Absolute)))

Looks a little suspect to me. I would expect it to be:-

new Uri(Session.ServerSecureURL + "/", UriKind.Absolute)))

Ordinarily cookes set in a folder (like "Login") would still have the path "/", since its usually intended that the cookies be available to the whole application.

Upvotes: 0

Related Questions