title: set php session on success of ajax
body: <p>I have problem .i am making ajax call to a php file that will check credentials, if true i want to redirect to page , but if false i want to show error. I have little bit problem . Here is my code ajax Code. </p>
  
  <pre><code>  function Login(val1, val2) {
                  alert(val1 + "\n" + val2);
                  $.ajax({
                      type: "POST",
                      url: "login.php",
                      data: 'username='+val1+'&amp;password='+val2,
                      success: function(data) {
                          alert(data);
                          if(data=="true"){
  
                              window.location.replace('./admin/index.php');
                          }else
                          $("#Area").html(data);
                      }
                  });
  </code></pre>
  
  <p>and this is my php code. </p>
  
  <pre><code>&lt;?php
  
    require_once '/admin/DbHelper.php';
  if (isset($_POST['password'])) {
      $pass = $_POST['password'];
      $name = $_POST['username'];
  
      $query = "select * from user_login where userName='$name' and userPass='$pass'";
      $result = mysqli_query($link, $query);
  
      $row=  mysqli_fetch_array($result);
  
  
      if ($row &gt; 0) {
          $_SESSION['userName'] = $name;
          echo "true";    } else {
          echo '&lt;label style="color:red"&gt; Invalid User Name or Passowrd !&lt;/label&gt;';
      }
  }
  </code></pre>
  
  <p>i can't understand where i should set session. please help me. </p>