Sunday, June 19, 2011

Windows Phone 7 – Quick Tip #29 – Working with Cookies

Bad-News/Good News – First the bad news: if you are building a Windows Phone 7 application and need to access the cookies for a request/response you are out of luck.  The good news is your app can successfully maintain cookies set by the server between requests.  That is to say if you make a call to the server, the server sets some sort of cookie, you can replay that cookie back to the server.  The limitation is you just aren’t allowed access to the cookie jar for your own consumption (to mix metaphors a little).

It’s really simple, just create an instance System.Net.CookieContainer which I usually call something like CookieJar and set it on the request object or on your C# code that you generate as a proxy for your service call.




I had thought we had access to cookies in Mango, but after checking in the latest drop of the development tools, it still looks like we don’t.  If I hear differently, I’ll update this post.


No comments:

Post a Comment