title: php can't read session value
body: <p>I'm working with a login.php page.
  when users login successfully, system will save their usernames into session.like below code:</p>
  
  <pre><code>if ($user != null) {
      $_SESSION['username'] = $user["username"];
      $_SESSION['userid'] = $user["id"];
      return 0;
  }
  </code></pre>
  
  <p>Then the page will be located to main.php.
  Main.php will read the session, like below code:</p>
  
  <pre><code>session_start();
  if (isset($_SESSION['username']) == false || empty($_SESSION['username']))
  {
      // transfer into login page
  }
  else
  {
      echo $_SESSION['username'];
  }
  </code></pre>
  
  <p>The main page can't read the $_SESSION['username'], the value is null.
  What should I do now?</p>