Authenticate with session storage

0

I have a login screen, where if the user logs a session storage with the required information, I also saw how I can read this recorded information, but how do I open a page through the URL to check if the session storage was if it is ok, let the page open, but redirect it to another. I'm using html5, javascritp, css, in that application I can not use a clint server language, PHP type, ASP NET or any other, I have to work exclusively on the client side, always consuming webservice using ajax.

Thank you

    
asked by anonymous 14.04.2017 / 05:18

1 answer

0

If the login is correct, create a session in your login page script

sessionStorage.setItem('Intelider', 'Sistemas');

Now just test if the session has expired on the protected pages:

  //recupera a session    
  var data = sessionStorage.getItem('Intelider');

  if (data == null){
     //exemplo
      window.location.href = 'suaPaginaDeLogin.html'; 
  }
    
14.04.2017 / 16:39