Access browser cookies from Web Player

Assume that the web player is embedded in a web page containing a flash application used to authenticate a user. Once the user is authenticated on the server, this one put a cookie in the user web browser to recognize subsequent http requests from this user. As the web player is part of the application, all the http requests from web player to the server need this cookie to allow the player to acces user data.

So I was wondering if Unity provides something to access browser cookies and get the one corresponding to the server domain? Do I have to do it manually through javascript?

2 Answers

2

Unfortunately Unity don't have such a function. If you're logged in via your website you would have to use Application.ExternalEval. Even if you use WWW to log in from your Unity app you have to parse the response header for the SetCookie header field.

Also watch out: The Unity WWW.responseHeaders (which are not documented yet) is a Hashtable! If your webserver returns multiple SetCookie header fields (which is legit by rfc2616 ) you will loose them except one due to the Hashtable. Hopefully it will be fixed soon ;)

Can I set this cookie from the client?

Also since I have the pro version, could I use .NET http classes in a dll to perform all my http connection functionality for the webplayer build?