. */ namespace SP\Core\Crypt; use SP\Http\Request; /** * Class SecureCookie * * @package SP\Core\Crypt */ class UUIDCookie extends Cookie { /** * Nombre de la cookie */ const COOKIE_NAME = 'SYSPASS_UUID'; /** * @param Request $request * * @return UUIDCookie */ public static function factory(Request $request): UUIDCookie { return new self(self::COOKIE_NAME, $request); } /** * Creates a cookie and sets its data * * @param string $signKey Signing key * * @return string|false */ public function createCookie(string $signKey) { $uuid = uniqid('', true); if ($this->setCookie($this->sign($uuid, $signKey))) { return $uuid; } return false; } /** * Loads cookie data * * @param string $signKey Signing key * * @return false|string */ public function loadCookie(string $signKey) { $data = $this->getCookie(); return $data !== false ? $this->getCookieData($data, $signKey) : false; } }