Javascript page redirection and session -


i have signup javascript function. correct redirect user(private page of user) through windiw.location function? work inside session scope? append httpcookie while redirecting request?

function signup()     {          var uname = document.forms[0].email.value;         var pass = document.forms[0].password.value;          var xmlhttp;         var response;         var url = "/v2/application/userlogin?fromclient=web&"+"email="+uname+"&password="+pass;         if (window.xmlhttprequest)         {// code ie7+, firefox, chrome, opera, safari             xmlhttp = new xmlhttprequest();         }         else         {// code ie6, ie5             xmlhttp = new activexobject("microsoft.xmlhttp");         }         xmlhttp.onreadystatechange = function()         {             if (xmlhttp.readystate === 4 && xmlhttp.status === 200) {                 response =  xmlhttp.responsetext;                 //alert(response);                 window.location = "/web/jsp/index.jsp?fromclient=web";              } else {                         //document.getelementbyid("mainwindow").innerhtml = "loading...";                         //alert("loding");             }         };         xmlhttp.open("post", url, true);         xmlhttp.send();           //alert(response);      } 

it acceptable redirect within ajax callback. however, when protected page requested, on server side must ensure user has authenticated session before display protected content.

will append httpcookie while redirecting request?

if server response included new cookie, yes sent when window.location request ocurrs.

side note: should url encode user input in url using encodeuricomponent() avoid special characters breaking url encoded format:

var url = "/v2/application/userlogin?fromclient=web&email="+ encodeuricomponent(uname)+"&password="+encodeuricomponent(pass); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -