- Home /
WWW standalone. (why changed web server session?)
I have one question. ^^
I make unity standalone version.
and make Web server (php+mysql).
if click client button, unity client communicate with web server.
Client source
WWW www ;
switch ( button_number )
case 0 :
String strUrl2 = String.Format("http://mydomain.com/WebPlayer.php?mode=Login&id=xxx&pass=xxx");
www = new WWW(strUrl);
case 1 :
String strUrl2 = String.Format("http://mydomain.com/WebPlayer.php?mode=Myinfo&id=xxx");
www = new WWW(strUrl);
case 2 :
String strUrl2 = String.Format("http://mydomain.com/WebPlayer.php?mode=Rankinginfo&id=xxx");
www = new WWW(strUrl);
//
If click button_number 0 -> call "Login" to Web server. If click button_number 1 -> call "Myinfo" to Web server....
It is correctly work. BUT... session of php web server is changed.
Whenever call web server, server session is changed.
Why change web-server session ??
Please help me~~~
Answer by Waz · Jul 04, 2011 at 12:14 PM
Unity WWW is not stateful, so you need non-stateful protocols ("REST" those web-weenies call it). Are you trying to use a session cookie or something like that?
Thank you~ Warwick Allison ^^
I want to use web-server session. Because... If user did loign, web-server session have(store) user's infomation.
what can i use for communicating with web-server?
Answer by Bunny83 · Jul 04, 2011 at 12:34 PM
You can either use the yet undocumented responseHeaders hashtable of the www class to get the Set-Cookie header after login and set the Cookie header with the session id each subsequent call.
The other way is to use an URI sessionID. Just pass the sessionID back to Unity when login, store it, and add an additional URI parameter: PHPSESSID=XXXXX for subsequent calls. PHP is that smart enough ;).
I guess the responseHeaders aren'T documented yet since a hashtable doesn't meet the http specs. A http header can be included multiple times in one response, the hashtable however overrides similar fields of course...
Thank you. Bunny83~
Please tell me reference URL or document ^^
Well, as i said the responseHeaders is undocumented. If you have Visual Studio you should have no problems to use it ;). It's just a Hashtable that contains all header fields.
Besides that you should take a look at the PHP manual especially the section about Passing the Session ID
Thank you for help.^^ I am trying to solve this problem. (I think.... I can do it~)
Have a nice day~~~
Your answer
![](https://koobas.hobune.stream/wayback/20220612132504im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Game object to prefab problem 0 Answers
Get session of web application by web player 0 Answers
API with Key Headers required 0 Answers
How to use POST service using www class? 0 Answers