Question

I am creating A login system using AJAX,PHP & SQL obviously.

Anyway I am trying to implement A real time login feature so it will log the user in without refreshing the page.

I have done that almost but the only issue when the user clicks remember me that uses cookies instead of sessions but the JQuery isn't proccessing that? I want it to detect depending if it was checked ether remember the user or not it only starts a session, when it does register a cookie the logout page is not deleting the cookie which he did before i added the jquery code in so nothing on the php end and I am mainly A PHP Developer and still learning. (I cannot post the server side code for privacy reasons as I be using this in A project but it looks similar to any other normal php login script)

Here's the JQuery

function validLogin(){
      var user_login=$('#user_login').val();
      var user_pass=$('#user_pass').val();
      var remember_me=$('#remember_me');


      var dataString = 'user_login='+ user_login + '&user_pass='+ user_pass;



      $("#flash").show();
      $("#flash").fadeIn(100).html('Loading..');
      $.ajax({
      type: "POST",
      url: "ajax/procces.php",
      data: dataString,
      cache: false,
      success: function(result){
               var result=trim(result);
               $("#flash").hide();
               if(result=='correct'){
                     window.location='index.php';
               }else{
                     $("#errorMessage").html(result);
               }
      }
      });
}

function trim(str){
     var str=str.replace(/^\s+|\s+$/,'');
     return str;
}

Thanks

Pas de solution correcte

Autres conseils

You don't pass your variable 'remember me' to your ajax request. For instance :

data: {login: user_login, passwd: user_pass, rememberMe: remember_me}

Another point, be careful you treat information from client-side. Never trust the client. Test all your values in PHP.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top