title: php lost $_SESSION value after click other site
body: <p>I have a method, in which I (twice) access this value:</p>
  
  <pre><code>$_SESSION['loggedinUser'];
  </code></pre>
  
  <p>The first time it works fine, but the second time the value has been lost.</p>
  
  <pre><code> public function View($view, $model) {
      if (! isset($_POST['regist'])
              &amp;&amp; ! isset($_POST['back'])
              &amp;&amp; ! isset($_POST['login'])
              &amp;&amp; ! isset($_GET['logout'])
              &amp;&amp; ! isset($_GET['note_list'])
              &amp;&amp; ! isset($_GET['file_list'])
              &amp;&amp; ! isset($_GET['profile'])
              &amp;&amp; ! isset($_GET['action'])) {       // LOGIN VIEW
          $view-&gt;login();
      }
  
      if (isset($_POST['regist'])) {               // REGIST
          $view-&gt;regist();
      }
  
      if (isset($_POST['back'])){                  // BACK
          $view-&gt;login();
      }
  
      if (isset($_POST['login'])) {                //LOGIN AND LOGGED IN VIEW
          $username = $_POST['user_name'];
          $pw = $_POST['pw'];
  
          if ($model-&gt;checLoginstatus($username, $pw) == true) {
              $id = $_SESSION['loggedInUser'];    // session is working fine
              session_start();
              $fname = $model-&gt;getNameToSession("user", "id", $id, 'firstname');
              $lname = $model-&gt;getNameToSession("user", "id", $id, 'lastname');
              echo "" . var_dump($id);
              $view-&gt;LoggedIn($fname . " " . $lname, null);
          }
      }
  
      switch ($_GET['action']) {
          case 'note_list':
              session_start();
              $id = $_SESSION['loggedInUser'];  // session gives back NULL
  
              $title = $model-&gt;getNameToSession("note", "user_id", $id, 'title');
              echo "" . var_dump($_SESSION['loggedInUser']);
              echo "" . var_dump($title);
              echo "&lt;a href='#'&gt;" . $title . "&lt;/a&gt;";
              break;
          case 'logout':
              session_start();
              session_unset();
              session_destroy();
              header("Location:/");
              break;
      }
  }
  </code></pre>
  
  <p>What am I doing wrong that the value is lost?</p>