i've my check_phone.php page on server as this:
<?php
session_start(); ob_start();
require '../platform2/pages/config.php';
require '../platform2/pages/function.php';
date_default_timezone_set('Europe/London');
if(isset($_POST['login']))
{
$email=mysql_real_escape_string(htmlspecialchars(trim($_POST['email'])));
$password=mysql_real_escape_string(htmlspecialchars(trim($_POST['password'])));
$stro = "select * from user where email='$email' and pwd='$password' ";
$res = mysql_query($stro) or die(mysql_error());
$login=mysql_num_rows($res);
if($login!=0)
{
echo "success";
} else {
echo "failed";
}
}
?>
And i call it from Jquery ajax call in my phonegap application in this way:
<script>
$("#login").click(function(){
var email=$("#email").val();
var password=$("#password").val();
var dataString="email="+email+"&password="+password+"&login=j";
var url = "../sandbox/platform/check_phone.php";
if($.trim(email).length>0 & $.trim(password).length>0)
{
$.ajax({
type: "POST",
url: url,
data: dataString,
crossDomain: true,
cache: false,
beforeSend: function(){ $("#login").html('Connecting...');},
success: function(data){
data = $.trim(data);
if(data=="success")
{
localStorage.login="true";
localStorage.email=email;
window.location.href = "wow.html";
/* in a normal php-application i used to store, $_SESSION['user'] $_SESSION['login'] , but i don't know how to do it in phonegap */
}
else if(data="failed")
{
alert("Login error");
alert(data);
$("#login").html('Login');
}
}
});
} return false;
});
</script>
Now, my question is: how i can save session of a User and continue to use his Session on a further request as retriving profile,make new post etc.. I've already thought to use SetLocalStorage as Username and Password, and call it with my request in every call. But i don't know if it make west time for my server than give me a slowly response. Is there a way for keeping session as i do on a normal request on my server?
Thanks