CodeIgniter v4.5 API

CookieStore
in package
implements Countable, IteratorAggregate

The CookieStore object represents an immutable collection of `Cookie` value objects.

Tags
implements

IteratorAggregate<string, Cookie>

see
CookieStoreTest

Table of Contents

Interfaces

Countable
IteratorAggregate

Properties

$cookies  : array<string, Cookie>
The cookie collection.

Methods

__construct()  : mixed
clear()  : void
Clears the cookie collection.
count()  : int
Gets the Cookie count in this collection.
dispatch()  : void
Dispatches all cookies in store.
display()  : array<string, Cookie>
Returns all cookie instances in store.
fromCookieHeaders()  : static
Creates a CookieStore from an array of `Set-Cookie` headers.
get()  : Cookie
Retrieves an instance of `Cookie` identified by a name and prefix.
getIterator()  : Traversable<string, Cookie>
Gets the iterator for the cookie collection.
has()  : bool
Checks if a `Cookie` object identified by name and prefix is present in the collection.
put()  : static
Store a new cookie and return a new collection. The original collection is left unchanged.
remove()  : static
Removes a cookie from a collection and returns an updated collection.
setCookie()  : void
Extracted call to `setcookie()` in order to run unit tests on it.
setRawCookie()  : void
Extracted call to `setrawcookie()` in order to run unit tests on it.
validateCookies()  : void
Validates all cookies passed to be instances of Cookie.

Properties

Methods

clear()

Clears the cookie collection.

public clear() : void

count()

Gets the Cookie count in this collection.

public count() : int
Return values
int

dispatch()

Dispatches all cookies in store.

public dispatch() : void
Tags
deprecated

Response should dispatch cookies.

display()

Returns all cookie instances in store.

public display() : array<string, Cookie>
Return values
array<string, Cookie>

fromCookieHeaders()

Creates a CookieStore from an array of `Set-Cookie` headers.

public static fromCookieHeaders(array<int, string> $headers[, bool $raw = false ]) : static
Parameters
$headers : array<int, string>
$raw : bool = false
Tags
throws
CookieException
Return values
static

get()

Retrieves an instance of `Cookie` identified by a name and prefix.

public get(string $name[, string $prefix = '' ]) : Cookie

This throws an exception if not found.

Parameters
$name : string
$prefix : string = ''
Tags
throws
CookieException
Return values
Cookie

getIterator()

Gets the iterator for the cookie collection.

public getIterator() : Traversable<string, Cookie>
Return values
Traversable<string, Cookie>

has()

Checks if a `Cookie` object identified by name and prefix is present in the collection.

public has(string $name[, string $prefix = '' ][, string|null $value = null ]) : bool
Parameters
$name : string
$prefix : string = ''
$value : string|null = null
Return values
bool

put()

Store a new cookie and return a new collection. The original collection is left unchanged.

public put(Cookie $cookie) : static
Parameters
$cookie : Cookie
Return values
static

remove()

Removes a cookie from a collection and returns an updated collection.

public remove(string $name[, string $prefix = '' ]) : static

The original collection is left unchanged.

Removing a cookie from the store DOES NOT delete it from the browser. If you intend to delete a cookie from the browser, you must put an empty value cookie with the same name to the store.

Parameters
$name : string
$prefix : string = ''
Return values
static

setCookie()

Extracted call to `setcookie()` in order to run unit tests on it.

protected setCookie(string $name, string $value, array<string|int, mixed> $options) : void
Parameters
$name : string
$value : string
$options : array<string|int, mixed>
Tags
codeCoverageIgnore
deprecated

setRawCookie()

Extracted call to `setrawcookie()` in order to run unit tests on it.

protected setRawCookie(string $name, string $value, array<string|int, mixed> $options) : void
Parameters
$name : string
$value : string
$options : array<string|int, mixed>
Tags
codeCoverageIgnore
deprecated

validateCookies()

Validates all cookies passed to be instances of Cookie.

protected validateCookies(array<string|int, mixed> $cookies) : void
Parameters
$cookies : array<string|int, mixed>
Tags
throws
CookieException

        
On this page

Search results