title: having trouble in php ajax login system
body: <p>i have a login system with ajax and php but after a sucessfull login my profile page still throw me out to main page.</p>
  
  <p>php code</p>
  
  <pre><code> if($_POST) 
    {
        $user_name     = strip_tags($_POST['user_name']);
  
        $password = ($_POST['password']);
  
        $user_name     = mysqli_real_escape_string($conn, $user_name);
        $password = mysqli_real_escape_string($conn, $password);
        $password=md5($password);
  
  
          $lselect_sql= "SELECT * FROM users WHERE user_name='{$user_name}'";
  
           $lselect_query = mysqli_query($conn, $lselect_sql);
  
          $lrow = mysqli_fetch_assoc($lselect_query);
  
  
          if($lrow['password']==$password){
  
      $_SESSION['user'] = $lrow['id'];
      echo "true";
      exit();
        }
        else
        {
  
           echo 'invalid credentials';
           }
        }
  </code></pre>
  
  <p>ajax code</p>
  
  <pre><code>$.ajax({
  
                  type : 'POST',
                  url  : 'login/login-fn.php',
                  data : $('#login-form').serialize(),
                  success : function(data)
                            {
                              if(data=='true')    {
  
                      window.location="/projectif/profile/home.php";
  
                              }else{
                               $("#login-result").html(data);
  
                              }
                            }
                  });
                  return false;
  
          }
          else
          {
              $("#login-result").html('');
          }
      });
  </code></pre>
  
  <p>profile page code</p>
  
  <pre><code>ob_start();
      session_start();
      require_once '../components/connectdb.php';
  
      // if session is not set this will redirect to login page
      if( !isset($_SESSION['user']) ) {
          header("Location: ../index.php");
          exit;
      }
      // select loggedin users detail
      $res=mysql_query("SELECT * FROM users WHERE id=".$_SESSION['user']);
      $userRow=mysql_fetch_array($res);
  </code></pre>
  
  <p>i think its all right bt dont know why this is happning.</p>