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 DaveA · May 10, 2011 at 12:48 AM · bugwebplayerwwwcookie

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

I know this feature is undocumented except in the release notes, but it also appears to be buggy.

My PHP uses setcoookie() to set a cookie, of course, and when I'm running the editor, I can get it no problem. However, in web player builds, this header is not there, as if it didn't exist. I see other headers there, but not the SET-COOKIE one.

Try

for (var r in www.responseHeaders)
  Debug.Log(r);

What gives?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · May 10, 2011 at 02:01 AM

The problem could be that the cookie is still set. The Webplayer does the www communication through the browser. A webserver will set a cookie only if needed. Since the cookie is transmitted with each www call there's no need for the server to set the cookie.

You can use Application.ExternalEval to get the cookie information from document.cookie. Furthermore the responseHeaders have a bug. They made it a Hashtable which seems quite handy in the first place but some HTTP header fields (like Set-Cookie) can be added multiple times. The Hashtable will only keep one of them... Some servers merge all Set-Cookies into one field but not all.

If you're not sure if the field is included or not i recommend WireShark ;)


edit

Well, just put this script on a GameObject and name the object "MyObject" (or what ever)

var cookieStr : String; var isLoaded = false; function UpdateCookieString() { isLoaded = false; Application.ExternalEval( "var unity = unityObject.getObjectById(\"UnityContent\");"+ "unity.SendMessage(\"MyObject\", \"OnGetCookie\", document.cookie);" ); }

function OnGetCookie(cookie : String) { cookieStr = cookie; isLoaded = true; }

Just make sure that the SendMessage function can find your GameObject. See the browser communication docs for more information.

ps. you can insert the object name directly into the eval string:

"unity.SendMessage(\"" + gameObject.name + "\", \"OnGetCookie\", document.cookie);"
Comment
Add comment · Show 6 · 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 DaveA · May 10, 2011 at 02:17 AM 0
Share

Yeah I saw your earlier post about this (thanks for that too!) but I doubt that it's getting intercepted by the browser. I suppose it's possible, but I'm making a www object request from within the player, after the scene is loaded. I'll try a header sniffer. Worst case I'll have it not use cookies.

avatar image DaveA · May 10, 2011 at 06:21 PM 0
Share

I used LiveHeaders in Firefox, and yup, my cookie is there. So why wouldn't it get passed down into the www response? I just have the one cookie. I hope they fix this next release. Also seems to depend on the browser. Firefox and IE ok, Chrome not.

avatar image DaveA · May 10, 2011 at 06:29 PM 0
Share

Bunny83, Q for you: How would you use ExternalEval to get the cookie? It doesn't return a value. Would you have it call a function which echos back a Send$$anonymous$$essage to set it on an internal function?

avatar image Bunny83 · May 10, 2011 at 08:55 PM 0
Share

I've added an example that should work ;). not tested ...

avatar image DaveA · May 10, 2011 at 11:14 PM 0
Share

Yup that's about what I came up with too, thanks!

Show more comments

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

No one has followed this question yet.

Related Questions

Workaround for SET-COOKIE bug in www.responseHeaders? 2 Answers

How do I properly send binary data (byte[]) to a MySQL database? 4 Answers

Having Trouble with Javascript GET and URL 1 Answer

Failed downloading http with WWW on Internet Explorer 0 Answers

Bytes array always empty in WWW object (on WebPlayer) 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