Results 1 to 2 of 2

Thread: html5 web session storage

  1. #1
    Join Date
    Aug 2013
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default html5 web session storage

    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

    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

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

  2. #2
    Join Date
    Aug 2013
    Posts
    86
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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
    Code:
    <!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>

Similar Threads

  1. Storage not working here
    By ceerup in forum Looking for such a script or service
    Replies: 0
    Last Post: 05-25-2012, 06:29 PM
  2. html 5 web storage
    By ceerup in forum JavaScript
    Replies: 2
    Last Post: 05-01-2012, 06:53 PM
  3. Resolved session in iFrame loses session data
    By crobinson42 in forum PHP
    Replies: 4
    Last Post: 02-29-2012, 12:59 AM
  4. Change cookies to local storage?
    By pxlcreations in forum JavaScript
    Replies: 1
    Last Post: 11-27-2011, 04:10 AM
  5. data storage
    By syazyan in forum PHP
    Replies: 10
    Last Post: 10-09-2006, 01:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •