CookieStorage

Learn how to persist the visitor session in cookies.

The cookie-based implementation of IdentityStore, persisting the visitor session, such as the client ID and user token, in cookies.

It is the default session store the SDK creates from the environment. You can also create one explicitly to customize the cookies, provide it when you create the SDK, then write the updated cookies before sending any output.

When you do not want to read or write cookies, such as in tests, use an in-memory store instead. It exposes the same interface but keeps the client ID and user token in memory.

Croct's mascot winking
Looking for something specific?

Use the search bar at the top of the page or press / to quickly search through the documentation.

Use the summary below to quickly jump to a specific topic:

PageDescription
ConstructorLearn how to initialize a cookie storage directly.
fromGlobalsLearn how to create a storage from the PHP superglobals.
fromServerRequestLearn how to create a storage from a PSR-7 server request.
fromArrayLearn how to create a storage from an array of cookies.
getResponseCookiesLearn how to get the session cookies to write to the response.
emitLearn how to write the session cookies to the response.