14

As I discovered here, when I make a call to a server to ask for authentication in the form of a cookie, the cookie in the response is handled automatically by the underlying metro framework.

However, this means I don't have access to the cookie and, therefore, cannot store it when the app is suspended for later use. How are we supposed to store cookie information in the metro framework?

All help is greatly appreciated and I always accept an answer!

danielmhanover
  • 3,094
  • 4
  • 35
  • 51
  • So you are basically asking how to transfer the cookies from the web compartment to the local compartment? Or, your not seeing the HTTP only cookie being kept away from the rest of the app? You have access to document.cookies, but I assume that's not working for Http Only. – Dominic Hopton Aug 06 '12 at 21:44
  • document.cookies returns undefined and document.cookie returns an empty string. I have tried both HTTPOnly cookies and non-httponly cookies, but the results for both kinds are the same – danielmhanover Aug 07 '12 at 14:53
  • So you are making an XHR, and you can't access the HTTP Only cookies? I thought that was the point of HTTP Only cookies? – Dominic Hopton Aug 07 '12 at 16:47
  • No, the problem is that I cant access ANY cookies. – danielmhanover Aug 07 '12 at 20:24
  • 2
    @DanielH. The answer to this question http://stackoverflow.com/questions/14362740/cookies-in-windows-8-winjs/14362804#14362804 should be helpful to you. – Konstantin Dinev Jan 27 '13 at 13:53
  • @Konstantin That is for ie10 what about win metro framework? These are apples and oranges. While I do not know the metro framework at all I have quite a bit experience with Android. Cookies are useless there. Local storage options (besides cookies) are what you need. – cliffbarnes Feb 24 '13 at 08:26
  • And what about using sessionStorage and ajax? – m93a May 21 '13 at 12:11
  • There is a known issue on Windows Phone apps regarding the subdomain of a cookie coming back - it will show as empty. [See this Stack Overflow Question for someone with similar issues](http://stackoverflow.com/questions/14108430/cookies-not-sent-on-windows-phone-app-but-cookies-are-sent-with-same-code-in-wi) it's well documented by the OP. – Markus Jun 05 '13 at 19:15

2 Answers2

1

We implemented sessionStorage for sessions and localStorage for persistence as a complete cookie replacement in our Windows 8 app and it has worked very well. Both storage engines are extremely straightforward to use, you can read up on them here: https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Storage

Rob M.
  • 35,491
  • 6
  • 51
  • 50
0

You wrote

cannot store it when the app is suspended for later use

I used Google Analytics in my Windows Store application, and I can say that cookies were successfully stored. You may ensure by checking the following filesystem location:

C:\Users\XXXX\AppData\Local\Packages\XXXXXX\AC\INetCookies

Docs at MSDN (link) also confirm that Cookies are supported method of storing user data.

If I understand correctly your question: you do not need take any additional action to accept and store network cookies in Windows Store apps.

amartynov
  • 4,125
  • 2
  • 31
  • 35