Why are Xbox One cookies lost after each HttpClient call and not persisted as stated in the Windows.Web.Http documentation?
Xbox One cookies using Windows.Web.Http are not updated and persisted after each HttpClient call and reused for any subsequent HttpClient call. Cookies have to be manually persisted and added before each HttpClient which not only problematic, but requires keeping separate code paths for Xbox One and PC / Desktops.
Universal Windows Platform (UWP)
-
Richard Zhang-MSFT • 6,936 Reputation points
2020-05-04T01:54:17.38+00:00 Hello, have you tried to create HttpBaseProtocolFilter before creating HttpClient? like this:
HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter(); var client = new HttpClient(filter);
HttpBaseProtocolFilter can help you save the cookie information without having to repeat the setting every time.
-
GW • 1 Reputation point
2020-05-04T22:41:52.837+00:00 Yes, we are doing that with each HttpClient call. This works on PCs, but cookies are not cached on the Xbox One. This is easily reproduced in Xbox One's Dev Home. Make a HttpClient call to any website such as the following in its own method:
HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter(); using(var client = new HttpClient(filter)) { string result = await httpClient.GetStringAsync(new Uri(url)); }
Call the method again and you can see that cookies are not added from the previous call.
-
Richard Zhang-MSFT • 6,936 Reputation points
2020-05-08T01:57:08.72+00:00 Sorry for the late reply, I am making a demo to try to reproduce your question. Before this, you need to confirm a few questions with you:
- When you test your app on Xbox, is it in the debug state or is the release version installed from the store?
- Is the setting to block cookies on your XBOX? (Open the Edge browser, there is an ellipsis button in the upper right corner, click the button and enter the settings, find the section about privacy and security, you can check whether the cookie is blocked).
- Did you log in to your account during the test on Xbox, and did your account have content restrictions enabled?
We will start testing as soon as possible and look forward to your reply. If any news, I will post it here.
-
GW • 1 Reputation point
2020-05-08T02:14:50.193+00:00 1) It's in the debug state
2) Cookies are allowed in Edge, I checked this a while back to be sure and recently double checked it. The option is set to "Don't block cookies"
3) I log into the same account which I use to test on PCs. It does not have restrictions and the Xbox One actually requires you to log into an account before you can run a debug session.
You may need to use Fiddler in order to see that no cookies are added from the first HttpClient call to any subsequent call when using the same domain. On the PC, you can see that cookies are automatically added when using the same domain.
-
Richard Zhang-MSFT • 6,936 Reputation points
2020-05-12T07:27:37.08+00:00 Hi, According to the test results of the engineer, on Xbox,
HttpBaseProtocolFilter
can record cookies normally and bring them into the next request. So we cannot reproduce your problem. You can try to update your Xbox to make sure it is up to date. If the problem persists, you can try another Xbox device or potentially an Xbox that has just been through the OOBE to set it up like new. -
GW • 21 Reputation points
2020-05-13T11:40:34.257+00:00 I've made a test program using the above code and I do see the cookies being recorded and used for subsequent requests. However, in my app I'm not seeing this occur. What are the situations in which the cookies would be cleared other than calling WebView.ClearTemporaryDataAsync()?
-
Richard Zhang-MSFT • 6,936 Reputation points
2020-05-15T05:38:53.93+00:00 Hi, there are many possibilities to clear cookies, such as those I mentioned above (user settings, or blocking cookie records in Edge, etc.) Without these, the cookie will not be cleared under normal circumstances, but if the cookie itself expires, or if the cookie is manually set to empty, the original cookie will also be cleared. You can check whether you have set the cookie code manually, or screen the network request to see if there is a similar situation.
-
GW • 21 Reputation points
2020-05-15T13:40:42.877+00:00 I don't believe it is something in the code, there has to be a difference between the PC and the Xbox One in some area. The same code on the PC retains cookies but on the Xbox One it does not within our application, but I have not been able to narrow it down. I do some have some ideas to try in my sample project. If I find something, is this the best place to report it?
-
Richard Zhang-MSFT • 6,936 Reputation points
2020-05-18T06:36:15.737+00:00 Indeed, this is not a problem with the code. According to the test results of the engineers, cookies are still retained on the Xbox, which may be related to some settings of the device. If you have new test results, you can choose to post them here. It is best to provide your test code sample, Xbox device type and system version. You can also go to the "Feedback Hub" application in Windows 10 to report your problems.
-
GW • 21 Reputation points
2020-05-26T20:16:55.03+00:00 It took a bit of work, but after removing assemblies one by one, it turns out the Microsoft Advertising SDK is what was causing cookies to not be shared. Since the SDK is being deprecated on June 1, we've removed it from our apps. Likely it had something to do with the XBox One crashing fix they put in over a year ago.
-
Richard Zhang-MSFT • 6,936 Reputation points
2020-05-27T06:24:43.833+00:00 I am very happy that you have found the cause of the problem, which is also a help to us. You can write the solution as an answer and accept it. This will help more people who meet the same problem.
Sign in to comment