locked
[UWP]Reading default browser cookies in a UWP app. RRS feed

  • Question

  • Can we access default device browser's cookies from inside a windows 10 application(UWP)?

    I want to open links from my app in the IE on a mobile device/desktop. These sites store some cookies on the system.

    I would like to access the cookies & send in subsequent requests. Hence, I want to only(or mostly) 'read' cookies.

    So, my question is "Can we access/read cookies from default device browser from a UWP app written in C#? If yes, how?"

    I searched a lot & tried following approaches:

    1. Using System.Net APIs: HttpWebRequest & CookieContainer to 'GetCookies'.

    2. HttpBaseProtocolFilter & HttpCookieManager to set/get cookies from internal WebView.

    but these don't serve the purpose.

    Second approach to this could be using an internal WebView & load urls in that and read cookies using second option mentioned above. But, do these urls store cookies automatically to WebView/appContainer, like they do when loaded in a desktop IE? I think they don't, & thus, I can't 'get' the cookies to pass on.

    Please suggest a suitable approach & solution.

    Appreciate any response in this regard. Thanks in advance.

    - Pritesh.



    Friday, July 3, 2015 10:48 AM

Answers

  • Hello PRITESH_LAD,

    >> Can we access default device browser's cookies from inside a windows 10 application(UWP)?

    Due to the restriction of windows runtime: https://msdn.microsoft.com/en-us/library/windows/apps/hh967755.aspx, we cannot read cookies from a default device browser(for example, the Internet explore) since these cookies are stored in the place where runtime applications cannot access. And for windows store application, it has a separate folder to store cookies:C:\Users\XXXX\AppData\Local\Packages\XXXXXX\AC\INetCookies.

    For reading the default device browser's cookies, you could check the Brokered Windows Runtime Components which is able to be Desktop component targeting to .NET 4.5. With it, we should be able to access these cookies, however please take care, this component is applied to Side-loaded application only.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Fred Bao Wednesday, July 15, 2015 5:42 AM
    • Marked as answer by Jamles Hez Wednesday, July 15, 2015 12:54 PM
    Monday, July 6, 2015 10:43 AM

All replies

  • Hello PRITESH_LAD,

    >> Can we access default device browser's cookies from inside a windows 10 application(UWP)?

    Due to the restriction of windows runtime: https://msdn.microsoft.com/en-us/library/windows/apps/hh967755.aspx, we cannot read cookies from a default device browser(for example, the Internet explore) since these cookies are stored in the place where runtime applications cannot access. And for windows store application, it has a separate folder to store cookies:C:\Users\XXXX\AppData\Local\Packages\XXXXXX\AC\INetCookies.

    For reading the default device browser's cookies, you could check the Brokered Windows Runtime Components which is able to be Desktop component targeting to .NET 4.5. With it, we should be able to access these cookies, however please take care, this component is applied to Side-loaded application only.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Fred Bao Wednesday, July 15, 2015 5:42 AM
    • Marked as answer by Jamles Hez Wednesday, July 15, 2015 12:54 PM
    Monday, July 6, 2015 10:43 AM
  • Thanks Fred.

    This confirms that we can't access IE cookies from a UWP app running on windows 10.


    - Pritesh Lad.

    Friday, July 24, 2015 7:57 AM