persist_cookie($session_key); return $session_key; } /** * Persist the wishlist session cookie. * * @param string $session_key Session key to store. * @return void */ public function persist_cookie(string $session_key): void { setcookie( self::COOKIE_NAME, $session_key, [ 'expires' => time() + self::COOKIE_TTL_SECONDS, 'path' => COOKIEPATH ? COOKIEPATH : '/', 'secure' => is_ssl(), 'httponly' => true, 'samesite' => 'Lax', ] ); $_COOKIE[self::COOKIE_NAME] = $session_key; } /** * Clear the wishlist session cookie. * * @return void */ public function clear(): void { setcookie( self::COOKIE_NAME, '', [ 'expires' => time() - YEAR_IN_SECONDS, 'path' => COOKIEPATH ? COOKIEPATH : '/', 'secure' => is_ssl(), 'httponly' => true, 'samesite' => 'Lax', ] ); unset($_COOKIE[self::COOKIE_NAME]); } }