1.2.5. Cookies

The Response retains each cookie as a Sapien\Response\Cookie value object.

1.2.5.1. Setting

1.2.5.1.1. Setting One Encoded Cookie

final public setCookie(
    string $name,
    string $value = '',
    int $expires = null,
    string $path = null,
    string $domain = null,
    bool $secure = null,
    bool $httponly = null,
    string $samesite = null
) : static

A buffered equivalent of setcookie(), with the various options expanded out to method parameters.

The method is fluent, allowing you to chain a call to another Response method.

1.2.5.1.2. Setting One Raw Cookie

final public setRawCookie(
    string $name,
    string $value = '',
    int $expires = null,
    string $path = null,
    string $domain = null,
    bool $secure = null,
    bool $httponly = null,
    string $samesite = null
) : static

A buffered equivalent of setrawcookie(), with the various options expanded out to method parameters.

The method is fluent, allowing you to chain a call to another Response method.

1.2.5.2. Getting

1.2.5.2.1. Getting One Cookie

final public getCookie(string $name) : ?Cookie

Returns the $name Cookie from the Response.

1.2.5.2.2. Getting All Cookies

final public getCookies() : array

Returns the array of Cookie objects in the Response.

1.2.5.3. Checking

final public hasCookie(string $name) : bool

Returns true if the $name Cookie exists in the Response, false if not.

1.2.5.4. Removing

1.2.5.4.1. Removing One Cookie

final public unsetCookie(string $name) : static

Removes the $name Cookie from the Response.

The method is fluent, allowing you to chain a call to another Response method.

1.2.5.4.2. Removing All Cookies

final public unsetCookies() : static

Removes all Cookie objects from the Response.

The method is fluent, allowing you to chain a call to another Response method.