jeudi 29 janvier 2015

html5 login localstorage for days


Html5 login localstorage for days. This HTML5 Login script uses localstorage to stores users that and everything works fine. But I need to add one more thing. I want once the user log in for the first time, the app will store the users info in html5 browser for like 30 days, when 30 days elapse, the user will be redirected back to login again. Can someone help me with that? Thanks.



<script>

$(document).ready(function(){

$('.send').click(function(){

var uname=$('#uname').val();
var pass=$('#pass').val();

if(uname==""){

$('.error').effect("bounce",500).fadeIn(400).html('Enter Your Username');

}

else if(pass==""){

$('.error').effect("bounce",500).fadeIn(400).html('Enter your password');

}

else{


$('.error').hide();
var userdata= "uname="+uname+"&pass="+pass;


window.localStorage["uname"] = uname;
window.localStorage["pass"] = pass;

$("#loader").show();
$("#loader").fadeIn(400).html('<img src="loader.gif" align="absmiddle">&nbsp;<span class="loading">Checking your details</span>');

$.ajax({

type:"post",
data:userdata,
url:"http://localhost/login.php",
cache:false,
success:function(msg){

$("#loader").hide();
$('.error').fadeIn(200).html(msg);

}

});



}
});

});

</script>




Aucun commentaire:

Enregistrer un commentaire