title: If isset $_SESSION goto this page?
body: <p>Ok, having trouble here:</p>
  
  <p>I created a login script, so after a person logs in then they will get direted to another page. And also, I have it redirecting them to the login page if they try and access one of those other pages.</p>
  
  <p>My problem is, if a user is logged in and stumbles to the login page again --by accident-- I would like for it to recognize that the user is logged in and redirect them to that next page (which is index2.php)  ?? Having troubles :-(</p>
  
  <p>Here is my code so far:</p>
  
  <pre><code>require_once "inc/functions.class.php";
  $quickprotect = new functions('inc/ini.php');
  
  if (isset($_SESSION['goAfterLogin'])){
      $goto = $_SESSION['goAfterLogin'];
      unset($_SESSION['goAfterLogin']);
  }
  else $goto = $quickprotect-&gt;settings['DEFAULT_LOGIN_SUCCESS_PAGE'];
  
  if (isset($_POST[username])) {
      if($quickprotect-&gt;login($_POST[username], $_POST[password])) header ("Location: $goto");
  }
  </code></pre>
  
  <p>Here is how I store a users session in the functions page</p>
  
  <pre><code> public function is_logged_in() {
          //Determines if a user is logged in or not. Returns true or false;
              if ($_SESSION['logged_in'] === md5($this-&gt;settings[ADMIN_PW])) {
                  return true;
              }
              else return false;
          }
  </code></pre>