title: cookies and sessions are not being saved
body: <p>my site is working (sort off). When i check if there sessions are there, they echo out a message which works BUT when i check session storage in chrome, the sessions are not coming up, which is strange. I have also tried to set a cookie but that is not coming up either. So what am i doing wrong. So the sessions are working but not getting stored, and the cookies are not getting stored either</p>
  
  <p>this is part of login class</p>
  
  <pre><code>public function __construct(DB $pdo)
  {
      $this-&gt;pdo = $pdo-&gt;pdo;
  
      if(isset($_GET['logout'])){
          $_SESSION = array();
          session_destroy();
      }
  
  }
  
  public function checklogin()
  {
      if(isset($_SESSION['user_sess']) &amp;&amp; $_SESSION['logged_in'] === true){
          return true;
      } else {
          return false;
      }
  }
  
  public function loginwithdata($email, $password)
  {
      $query = $this-&gt;pdo-&gt;prepare('SELECT * FROM `users` WHERE `email` = ?');
  
      $query-&gt;bindValue(1, $email);
  
      try{
  
      $query-&gt;execute();
  
      $data = $query-&gt;fetch();
  
      $salt = $data['salt'];
      $user_key = $data['user_key'];
      $hashed_pass = sha1(md5($salt.$password));
  
      if($this-&gt;verify($hashed_pass, $email) === true){
  
          $_SESSION['user_sess'] = $user_key;
          $_SESSION['logged_in'] = true;
          setcookie('key', '12345678910', 1209600, '/');
          return true;
      } else {
          return false;
      }
  
      } catch(PDOException $e) {
          die($e-&gt;getMessage());
      }
  }
  </code></pre>
  
  <p>here is the ajax_login.php</p>
  
  <pre><code>require '../core/init.php';
  
  if(isset($_POST))
  {
      $email = $_POST['email'];
      $password = $_POST['password'];
  
      if(!empty($email) &amp;&amp; (!empty($password))){
  
          $try = $login-&gt;loginwithdata($email, $password);
  
          if($try){
              //login successful
              echo 'success';
          } else {
              echo 'login failed';
          }
      }
  } 
  
  and on my index page i have
  
  require_once 'core/init.php';
  
  if($login-&gt;checklogin() === true){
      echo "you are logged in";
  } else if ($login-&gt;checklogin() === false) {
      echo "you are not logged in";
  }
  </code></pre>
  
  <p>and my init file</p>
  
  <pre><code>session_start();
  error_reporting(E_ALL);
  date_default_timezone_set('Europe/London');
  
  require_once 'classes/DB.php';
  require_once 'classes/Upload.php';
  require_once 'classes/Login.php';
  require_once 'classes/Register.php';
  require_once 'classes/Site.php';
  require_once 'classes/Admin.php';
  
  require_once 'sinitize.php';
  
  $pdo        = new DB;
  $upload     = new Upload($pdo);
  $login      = new Login($pdo);
  $register   = new Register($pdo);
  </code></pre>