getDomain

Learn how to read the cookie domain.

This method provides the domain of the cookie.

Signature

This method has the following signature:

public function getDomain(): ?string

This method returns the domain of the cookie, or null when it is not scoped to one.

Example

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

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