Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by MHatfull · Oct 18, 2017 at 01:18 PM · webglwww classcookie

WWW request has missing Cookie header.

I've been upgrading our project from unity 5.4 to unity 2017.1 and have struck a problem with our WebGL build. Previously we would send an init request to the server which would return us a cookie in the response headers (Set-Cookie header) and then this cookie would end up in the following requests to the server in a Cookie header. we never touched the cookie in our CS code so presumably either the WWW class or the browser itself just handled it. Now with 2017.1 we make the same init request to our server, we receive the set-cookie header back as expected but the following requests to the server do not have a cookie in the request headers. What am I doing wrong?

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MHatfull · Oct 18, 2017 at 01:19 PM 0
Share
             WWWForm form = CreateFormFromObject(payload);
             form.AddField("rqn", rqn);
             form.AddField("last$$anonymous$$essageId", _last$$anonymous$$essageId);
             form.AddField("lastPrimaryId", _lastPrimaryId);
             form.AddField("lastSecondaryId", _lastSecondaryId);
 
             if (retries != 0)
             {
                 form.AddField("rqnRetry ", retries);
             }
 
             string url = _host + "/quiz/" + endPoint.ToString();
 
             string qId = _quizID == 0 ? "null" : _quizID.ToString();
             url += "?identifier=" + qId + "-" + _userID + "-" + _pollNumber;
             _pollNumber++;
 
             Dictionary<string, string> headers = form.headers;
 
 #if UNITY_EDITOR || !UNITY_WEBGL
             if (_cookie != null)
             {
                 headers.Add("Cookie", _cookie);
             }
 #endif
 
             WWW www = new WWW(url, form.data, headers);

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by MHatfull · Oct 18, 2017 at 02:11 PM

We have found the issue. In our codebase we have the following code (run when the page loads):

 (function(window) {
   var original = XMLHttpRequest;
   window.XMLHttpRequest = function() {
     var x = new original;
     x.withCredentials = true;
     return x;
   };
 })(window);

Due to some reasons I had deleted the file that contained it without knowing this had gone too. This code lets the browser set the authentication of the requests and fixes the problem.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

121 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

WebGL Build WWW class : Unknown Error 1 Answer

the latest version of unity physics? 0 Answers

Why does my toon shader not work when I build it in webgl? 0 Answers

How to capture Camera disconnect in using Webcamtexture for Webgl 1 Answer

Unity says my platformer micro game cannot be shared with webGL because the max size is 100 mb, but I should be able to share it 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges