title: Multiple session id generated for different page of same website in PHP
body: <p>PHP is unable to store the $_SESSION variable's value or indexes across the login page &amp; the landing page. At first the problem was that with each page request a new SESSION ID was generated. But the even after that problem was solved it is unable to identify the $_SESSION variable's value or indexes.</p>
  
  <p><strong>Login page Code</strong></p>
  
  <pre><code>if(mysqli_num_rows($data) == 1)
  { 
      setcookie('user_id',$row['user_id'],time()+(60*60*24));
      setcookie('username',$row['username'],time()+(60*60*24));
      echo $row['user_id'];
      $name = $row['username'];
      if(!empty($_COOKIE['user_id'])&amp;&amp;!empty($_COOKIE['username']))
      header('Location: '."home.php",200);
      else
      {
          $_SESSION['user_id']=$row['user_id'];
          $_SESSION['username']= $name;
          header('Location: '."home.php",200);
      }
  }
  </code></pre>
  
  <p><strong>Landing Page Code</strong></p>
  
  <pre><code>&lt;?php
  session_start();
  if (isset($_SESSION['PHPSESSID'])) {
      header('Location: '."index.php",200);
  }
  else{
     echo "Hello".$_SESSION["username"];
  }
  ?&gt;
  </code></pre>
  
  <p><strong>PHP.ini File Configuration</strong></p>
  
  <p>session.use_cookies On  On</p>
  
  <p>session.use_only_cookies    On  On</p>
  
  <p>session.use_strict_mode Off Off</p>