Elgg\PersistentLoginService::storeHash PHP Method

storeHash() protected method

Store a hash in the DB
protected storeHash ( ElggUser $user, string $hash ) : void
$user ElggUser The user for whom we're storing the hash
$hash string The hashed token
return void
    protected function storeHash(\ElggUser $user, $hash)
    {
        // This prevents inserting the same hash twice, which seems to be happening in some rare cases
        // and for unknown reasons. See https://github.com/Elgg/Elgg/issues/8104
        $this->removeHash($hash);
        $time = time();
        $hash = $this->db->sanitizeString($hash);
        $query = "\n\t\t\tINSERT INTO {$this->table} (code, guid, timestamp)\n\t\t    VALUES ('{$hash}', {$user->guid}, {$time})\n\t\t";
        try {
            $this->db->insertData($query);
        } catch (\DatabaseException $e) {
            $this->handleDbException($e);
        }
    }