- Home /
Cant stay logged in server with www class
first i apologize if i dont get this question right....... but im new to this forum as well as to Unity , so i have my scene and i made a login and register system for it using the www class and got it " working " , i can post the register info , and log in , i get a JSON response from the REST server with my user id and name as well as last log and update on the " www.text" but when i try to upload more info as a logged user it gives me the 403 error and i cant figue out why it is, i can only think it does not stay logged, i have already tested the post and get params with Chrome´s Advance REST Client App and it is working fine , i would appreciate some help with this since ive been stuck on this for a while.
here is the code im using for the forms
function login() {
var form = new WWWForm();
form.AddField("user",user); form.AddField("pass",pass); var headers = form.headers; var rawData = form.data; var url = "the login URL"; headers["X-API-KEY"]="the key";
var www = new WWW(url, rawData, headers);
yield www;
if (www.error != null)
print(www.error);
else
Sync();
}
function Sync() {
var form = new WWWForm();
form.AddField("param","value1");
var headers = form.headers; var rawData = form.data; var url = "the sync URL"; headers["X-API-KEY"]="the key"; var www = new WWW(url, rawData, headers);
yield www;
if (www.error != null)
print (www.error);
else
print (www.text);
}
Thank you in Advance for any of the great help..........
Presumably when you log in, the server returns some data to you that says you are logged in. I suspect this data might need to be provided in subsequent requests to the server.
Your answer
Follow this Question
Related Questions
How to use POST service using www class? 0 Answers
How Do i check for Duplicate username in database 4 Answers
how can get cookie header data from web page in unity? 1 Answer
sending values to server script 1 Answer
WWW and cookies/login 3 Answers