title: Why is my SESSION variable undefined on host but not locally
body: <p>I'm from the Netherlands and my English isn't perfect, but I will try my best.</p>
  
  <p>My problem is as followed:
  I've made a local website with Wampserver and everything worked fine on it, but now I've bought hosting and my SESSION variable doesn't work anymore.</p>
  
  <p>The code of the function:</p>
  
  <pre><code>public function login($uname,$umail,$upass)
  {
      try
      {
          $stmt = $this-&gt;db-&gt;prepare("SELECT * FROM users WHERE user_name=:uname OR user_email=:umail LIMIT 1");
          $stmt-&gt;execute(array(':uname'=&gt;$uname, ':umail'=&gt;$umail));
          $userRow=$stmt-&gt;fetch(PDO::FETCH_ASSOC);
          if($stmt-&gt;rowCount() &gt; 0)
          {
              if(password_verify($upass, $userRow['user_pass']))
              {
                  $_SESSION["user_session"] = $userRow['user_id'];
                  return true;
              }
              else
              {
                  return false;
              }
          }
      }
      catch(PDOException $e)
      {
          echo $e-&gt;getMessage();
      }
  }
  </code></pre>
  
  <p>Code of the page where I try to check if someone is logged in:</p>
  
  <pre><code>        if(!$user-&gt;is_loggedin())
      {
          $user-&gt;redirect('login.php');
      }
  $user_id = $_SESSION['user_session'];
  </code></pre>
  
  <p>And then the error I'm getting:
  Undefined index: user_session in /mnt/web515/b0/72/510494272/htdocs/admin/index.php on line 8</p>
  
  <p>Can someone please help me figure out why user_session is undefined now but not when I locally run the website?</p>
  
  <p>Thanks in advance!</p>