Quantcast
Channel: Questions in topic: "httpwebrequest"
Viewing all articles
Browse latest Browse all 190

Login cookies

$
0
0
I have created a simple login with Unit, php and mysql for Android devices. However I am facing difficulties to understand how cookies work and are the cookies the right way to persist the authentication next time when the game is opened. As far as I have seen I can create cookies in two ways: *- Create cookies in Unity with **responseHeaders** - Create cookies in php with **setcookies** method and then retrieve those values in Unity* Or am I wrong and those two options need to be combined to create cookies? Below is my existing code. Can someone help me to modify the code so I can manage cookies? **Unity** IEnumerator LoginPlayer() { WWWForm form = new WWWForm(); form.AddField("name", loginNameField.text); form.AddField("password", loginPasswordField.text); WWW www = new WWW("http://.../login.php", form); yield return www; if (www.text[0] == '0') { ... LoginSucessfully(); } else { Debug.Log("User login failed. Error #" + www.text); } } **PHP** ... $username = $_POST["name"]; $password = $_POST["password"]; //check if name exists ... //get login info from query $existinginfo = mysqli_fetch_assoc($namecheck); $salt = $existinginfo["salt"]; $hash = $existinginfo["hash"]; $loginhash = crypt($password, $salt); if($hash != $loginhash){ echo "6: Incorect Password"; exit(); } ...

Viewing all articles
Browse latest Browse all 190

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>