getResponseCookies

Learn how to get the session cookies to write to the response.

This method provides the session cookies to write to the response, reflecting the saved client ID and user token.

Use it when integrating with a framework that manages the Set-Cookie headers itself, instead of emit for plain PHP scripts.

Signature

This method has the following signature:

public function getResponseCookies(): array

This method returns a list of two Cookie objects to set on the response: the client ID cookie and the user token cookie.

Example

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

<?phpuse Croct\Plug\CookieStorage;
$storage = CookieStorage::fromGlobals();$cookies = $storage->getResponseCookies();