title: "Notice: Undefined index" when trying to read $_SESSION array
body: <p>I have an irritating problem and I can't seem to fix it, I watched some videos on YouTube and read through the php.net documentation about error but this <code>$_SESSION</code> error needs your help!</p>
  
  <p>The exact error, I get is this: </p>
  
  <pre><code>Notice: Undefined index: previouspage
  C:\Users\Administrator\Documents\Localhost\root\test\index.php on line 5
  </code></pre>
  
  <p>What I have created is a goback button using a session variable. When the variable is already defined in my script there's no problem but when "the user" visits the website for the first time there is no "previous page" yet. The error above is what I then get. How can I fix this?   </p>
  
  <p>I have this PHP code:</p>
  
  <pre><code>&lt;?php 
  
  session_start();
  
  if($_SESSION["previouspage"]) {
      echo "&lt;a href=".$_SESSION["previouspage"]."&gt;Go back.&lt;/a&gt;";
      $_SESSION["previouspage"] = "index.php";
  }else {
      //No go back button will be displayed.
      $_SESSION["previouspage"] = "index.php";
  }
  </code></pre>
  
  <p>?></p>
  
  <p>So, when there's no history yet I get the error, otherwise not. How to fix this?</p>