Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
1
Question by nventimiglia · Nov 13, 2013 at 01:01 AM · wwwauthentication4.3cookie

Cookie Header With WebPlayer Unity3d 4.3

Setting the cookie header with webplayer worked in Unity 4.2 but fails in Unity 4.3.

To replicate

             var headers = new Hashtable{{"Cookie", "CookieValue" }};
             var www = new WWW("http://google.com", new byte[1], headers);    
             yield return www;

The error message is

ArgumentException: Cannot overwrite header: Cookie

UnityEngine.WWW.CheckSecurityOnHeaders (System.String[] headers) (at C:/BuildAgent/work/d3d49558e4d408f4/Runtime/Export/WWW.cs:67)

UnityEngine.WWW..ctor (System.String url, System.Byte[] postData, System.Collections.Hashtable headers) (at C:/BuildAgent/work/d3d49558e4d408f4/artifacts/EditorGenerated/Utils.cs:72) I read the change log for 4.3. It had no mention of this change. Not sure what to do, authentication cookies are kinda important to me.
Comment
Add comment · Show 2
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 WildMaN · Nov 21, 2013 at 10:50 AM 0
Share

Have same problem, and no workaround :(

avatar image DarkPlan · Mar 24, 2014 at 02:51 PM 0
Share

I am facing the exact same problem. It seems like ever since Unity 4.3 was released there are many new issues with security checks blocking legitimate actions...

The same code works on other environments (like standalone). However upon switching to web player environment this fails to work.

3 Replies

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

Answer by nventimiglia · Nov 13, 2013 at 05:15 AM

I have a work around. Dont use Cookies to authenticate. You could use basic authentication for instance - and encode the username and password into a header field.

I ended up injecting my authentication cookie into the header and then augmented my server code to reattach it as a cookie to the request before authentication took place. Kind of an odd solution, but I can reuse all my cookie dependent authentication stuff.

Comment
Add comment · Show 2 · 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
avatar image bustedkrutch · Apr 14, 2014 at 09:15 PM 0
Share

Would you please share your reattachment code pls pls pls. I'm assu$$anonymous$$g php, although maybe not.

I've been coding just enough php to get mysql in shape but I really want to make use of session variables. I'm sure I can get the session id back to my php, but I don't know enough about session handling to pull of "reinstating" the passed back id as the session id for the script that is receiving it.

Did I ask please :)

avatar image bustedkrutch · May 09, 2014 at 01:05 AM 0
Share

I figured it out! :)

avatar image
3

Answer by GeorgeCrane · Nov 26, 2013 at 10:37 AM

How to fix this: Clear the generated folders, like library, temp and object.

Steps to replicate the bug and solution:

  1. Install unity 4.2.

  2. Create a new project 'A' using 4.2, note that op's code works.

  3. Upgrade to unity 4.3.

  4. Create a new project 'B' using 4.3, note that again op's code works.

  5. Open and upgrade the 4.2 project 'A' to 4.3, note you get the Exception.

  6. Clear the generated folders in project 'A', note that op's code works.

I guess unity 4.3 has a updated library but does not update/invalidate generated code when it upgrades the projects.

Comment
Add comment · Show 5 · 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
avatar image Bunny83 · Nov 26, 2013 at 11:31 AM 0
Share

Great to know! It just baffles me why some serialized project data / setting is affecting "CheckSecurityOnHeaders". I smell some global state here :D

ps: To all who wants try this method:

  • $$anonymous$$ake sure you have a backup of your project

  • Also you should enable meta files in the settings or deleting the library folder will break your project.

  • Finally verify you have a working backup ;)

If something goes wrong, don't blame GeorgeCrane ;)

avatar image GeorgeCrane · Nov 26, 2013 at 01:02 PM 0
Share

Good point, cheers Bunny83.

avatar image nventimiglia · Nov 26, 2013 at 10:35 PM 0
Share

I dont understand your solution. What is this "CheckSecurityOnHeaders" setting ? I looked in project settings and on google and found nothing. I`snt this just a web-player sandbox security issue ?

avatar image insominx · Dec 06, 2013 at 07:03 PM 0
Share

I was having this problem using GameAnalytics and this method solved it for me. Thanks!

avatar image NickCauldron · May 08, 2014 at 04:45 PM 0
Share

This works for me too, but the error reappears periodically (meaning I then have to clear my Library and Temp directories again to get rid of it). Has anyone come across a proper fix for this?

avatar image
1

Answer by NickCauldron · May 12, 2014 at 11:05 AM

For anyone else still struggling with this problem:

For me, it seems to only affect the Editor when running with WebPlayer as the build target (which, if your project is a web one, is probably most of the time!). To avoid the problem and get on with your development, simply switch the build target to PC & Mac Standalone, and the issue goes away. When deploying, you then need to simply switch it back - it doesn't seem to affect deployed WebPlayer builds, only in the Editor. Of course, if this does seem to affect your deployed builds, you can always nuke your temporary directories and re-deploy - which at least you'll have to do far less frequently.

I'm posting this as an answer on the grounds that it's arguably a workaround. It's also possibly an explanation for GeorgeCrane's directory-nuking solution above, as one of the files in there stores the current build target - so by deleting them, the build target is reset to Standalone, which then appears to work.

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

24 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

Related Questions

Overwrite "cookie" in header throw exception in web player. 0 Answers

WWW class with authentication 0 Answers

Here's how I used Django to do User Auth in Unity3d 0 Answers

Sending cookie to XML-RPC protocol 0 Answers

WWW responseHeaders not giving me cookie in web-player, but does in editor 1 Answer


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