How my script works:
- index.php gets the file sends it to the jscript to analyze it, then it send to the upload.php where the session it should be.
But the Session is null. if i go to the upload.php and print the variable it shows my usernumber 2(works)
require_once("user/upload_session.php");
if (!isset($_SESSION)) { session_start();}
Login to create session:
public function doLogin($uname,$umail,$upass)
{
    try
    {
        $stmt = $this->conn->prepare("SELECT id, user_name, email, pass FROM accounts WHERE user_name=:uname OR email=:umail ");
        $stmt->execute(array(':uname'=>$uname, ':umail'=>$umail));
        $userRow=$stmt->fetch(PDO::FETCH_ASSOC);
        if($stmt->rowCount() == 1)
        {
            if(password_verify($upass, $userRow['pass']))
            {
                $_SESSION['user_session'] = $userRow['id'];
                  $thatsmysession = $_SESSION['user_session']; 
                return true;
            }
            else
            {
                return false;
            }
        }
    }
    catch(PDOException $e)
    {
        echo $e->getMessage();
    }
}
well im using this:
if (empty($thatsmysession)) {
    // Query if user is NOT logged in
    $q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ' .
                      'expire, delid, ip) VALUES (:hash, :orig, :name, :size, :date, ' .
                      ':exp, :del, :ip)');
} else {
          
    // Query if user is logged in (insert user id together with other data)
    $q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ' .
                      'expire, delid, user, ip) VALUES (:hash, :orig, :name, :size, ' .
                      ':date, :expires, :delid, :user, :ip)');
    $q->bindValue(':user', $thatsmysession, PDO::PARAM_INT);
}
Only there at $q->bindValue(':user', $thatsmysession, PDO::PARAM_INT); the session is null but if i echo to test if the variable is correct it works
 
     
     
     
    