I’m trying to make an interface for a browser-based game. I need to be able to have the user log in, which if I’m not mistaken means I need to send a cookie with the WWW request. I don’t see a way for that to be done. Am I missing it, or is it not possible with the WWW class?
You can use the responseHeaders of the WWW class. It is still undocumented. It’s simply a Hashtable / Dictionary of all header fields from the last response. Keep in mind that webservers don’t send a “Set-Cookie” header when you passed the cookie in the request header. For the request headers you have to use the third version of the WWW constructor, which you can find at the bottom of this page.
So when you send your login POST request without a “Cookie” header, the Webserver should include a SetCookie header with your session ID. Next time you send a request you would include a “Cookie” header in your request. The response usually don’t include another Set-Cookie since the server knows you have the cookie.
For more information see Cookie.
This might not be what you’re looking for, but if cookies will fit your purpose, you could use this to call a function in the HTML file in which your webplayer is embedded. Within that file, you could then write JS code similar to this to write/read a cookie.
We have similar problem as www merges all SET_COOKIEs in one pair. Sadly I can see all the cookies in the www.responceHeadersString but the variable is protected and the www.responceHeader’s data has been corrupted.
Any solutions?
Your kind attention is highly appreciated guys.