Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

html5 web storage session login

session

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 mutago

mutago

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 478 posts

Posted 11 May 2014 - 12:43 PM

i want to create a web storage session login and print  a successful  page (welcome.html) with the

loggin session username and password.

 

Login form works but those not display the welcome user on the successful page. any help

 

below is the code

 

$(document).ready(function(){
 $("#rolling").slideDown('slow');
});
$(document).ready(function()
 {
$("#submit").click(function()
{
if($("#uname").val()=="" || $("#pass").val()=="")
{
$("p").fadeTo('slow','0.99');
$("msg").hide();
$("p").fadeIn('slow',function(){$("p").html("<span id='error'>Please enter username and password</span>");});
return false;
}
else
{
 
 
 
$("p").html('<span class="normal"><img src="loading.gif"></span>');
var uname = $("#uname").val();
var pass = $("#pass").val();
$.getJSON("server.php",{username:uname,password:pass},function(json)
{
// Parse JSON data if json.response.error = 1 then login successfull
if(json.response.error == "1")
{
 
 
                      //store session
                window.localStorage["uname"] = uname;
                window.localStorage["pass"] = pass;             
              $.mobile.changePage("welcome.html");
 
}
// Login failed
else
{
 
data = "<span id='error'>Invalid account?</span>";
}
 

 

 

welcome.html

 

<!DOCTYPE HTML>
<html>
<head>
</head>
 
<body>
 
data = "<span id='msg'>Welcome "+uname+"</span>";
 
</body>
</html>
 
 


#2 mutago

mutago

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 478 posts

Posted 13 May 2014 - 12:22 PM

Below is what am trying achieve, when a user login, on the successful page, it alerts eg welcome user, how will i print the welcome user on the body of the html as opposed to alerting it on the head
 
<!DOCTYPE HTML>
<html>
<head>
 
<script>
//sessionStorage.setItem('uname');               // defining the localStorage variable
alert("welcome: " + localStorage.getItem('uname'));  // accessing it
confirm("welcome " + localStorage.uname);                     // another way of accessing the variable
 
 
</script>
 
 
</head>
 
<body>
 
 
welcome: " + localStorage.getItem('uname'); 
 
</body>
 
any help
</html>
 
 





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download