getExpiration

Learn how to read the cookie expiration time.

This method provides the expiration time of the cookie.

Signature

This method has the following signature:

public function getExpiration(): ?int

This method returns the expiration time as a Unix timestamp in seconds, or null for a session cookie.

Example

Here is a basic example of how to use this method:

<?phpuse Croct\Plug\CookieStorage;
$cookies = CookieStorage::fromGlobals()->getResponseCookies();$expiration = $cookies[0]->getExpiration();