{"id":3071,"date":"2014-11-21T10:30:26","date_gmt":"2014-11-21T18:30:26","guid":{"rendered":"http:\/\/www.cloudidentity.com\/blog\/?p=3071"},"modified":"2014-11-21T10:30:26","modified_gmt":"2014-11-21T18:30:26","slug":"getting-rid-of-residual-cookies-in-windows-store-apps","status":"publish","type":"post","link":"https:\/\/www.cloudidentity.com\/blog\/2014\/11\/21\/getting-rid-of-residual-cookies-in-windows-store-apps\/","title":{"rendered":"Getting Rid of Residual Cookies in Windows Store Apps"},"content":{"rendered":"<p>This is a classic Q I get pretty often \u2013 it\u2019s time to get a post out and start replying by reference instead of by value <img decoding=\"async\" class=\"wlEmoticon wlEmoticon-smile\" style=\"border-top-style: none; border-bottom-style: none; border-right-style: none; border-left-style: none\" alt=\"Smile\" src=\"https:\/\/www.cloudidentity.com\/blog\/wp-content\/uploads\/2014\/11\/wlEmoticon-smile2.png\"><\/p>\n<p>The issue at hand is how to fully \u201csign out\u201d (whatever that means for a native app) a user from a Windows Store client. <\/p>\n<p>The actual user session is determined by two different components: the token cache (under ADAL&#8217;s control, see <a href=\"https:\/\/www.cloudidentity.com\/blog\/2014\/07\/09\/the-new-token-cache-in-adal-v2\/\">this<\/a>) and any session tracking cookies that might be present in the system (<strong>not<\/strong> under ADAL&#8217;s control). As shown in the aforelinked post, you can easily take care of the token cache part. Clearing cookies is harder tho, Windows Store authentication takes place within the WebAuthenticationBroker &#8211; which has its own cookie jar that is separate and unreachable from your application code. The most robust approach there is not to create any persistent cookie (e.g. NOT clicking &#8220;remember me&#8221; during authentication. In fact, we should stop even showing it soon). However if you end up with such a cookie, the main way of getting rid of it is triggering a sign out form the same WebAuthenticationBroker &#8211; the server will take care of cleaning things up. <\/p>\n<pre class=\"csharpcode\">    <span class=\"kwrd\">string<\/span> requestUrl = <span class=\"str\">\"https:\/\/login.windows.net\/common\/oauth2\/logout\"<\/span>;\n    Task.Run(async () =&gt;\n    {\n        <span class=\"kwrd\">try<\/span>\n        {\n            await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.SilentMode, <span class=\"kwrd\">new<\/span> Uri(requestUrl));\n        }\n        <span class=\"kwrd\">catch<\/span> (Exception)\n        {\n            <span class=\"rem\">\/\/ timeout. That's expected<\/span>\n        }\n    });\n<\/pre>\n<style type=\"text\/css\">.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }\n<\/style>\n","protected":false},"excerpt":{"rendered":"<p>This is a classic Q I get pretty often \u2013 it\u2019s time to get a post out and start replying by reference instead of by value The issue at hand is how to fully \u201csign out\u201d (whatever that means for a native app) a user from a Windows Store client. The actual user&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3071","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.cloudidentity.com\/blog\/wp-json\/wp\/v2\/posts\/3071","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudidentity.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudidentity.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudidentity.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudidentity.com\/blog\/wp-json\/wp\/v2\/comments?post=3071"}],"version-history":[{"count":1,"href":"https:\/\/www.cloudidentity.com\/blog\/wp-json\/wp\/v2\/posts\/3071\/revisions"}],"predecessor-version":[{"id":3072,"href":"https:\/\/www.cloudidentity.com\/blog\/wp-json\/wp\/v2\/posts\/3071\/revisions\/3072"}],"wp:attachment":[{"href":"https:\/\/www.cloudidentity.com\/blog\/wp-json\/wp\/v2\/media?parent=3071"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudidentity.com\/blog\/wp-json\/wp\/v2\/categories?post=3071"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudidentity.com\/blog\/wp-json\/wp\/v2\/tags?post=3071"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}