abstract class AbstractCookie implements CookieInterface (View source)

Base class, to be estended implementing a CookieInterface

Properties

protected string $name The cookie name
protected string $value Cookie value (native string or serialized one)
protected integer $expire Expiration time
protected string $path Path of cookie
protected string $domain Domain of cookie
protected bool $secure Secure flag
protected bool $httponly Httponly flag
$max_cookie_size

Methods

__construct(string $name, int $max_cookie_size = null)

Default cookie's constructor

setName(string $name)

Set cookie name

string
getName()

Get cookie name

setValue(string $value, bool $serialize)

Set value of cookie

string
getValue(bool $unserialize)

Get cookie value

setExpire($timestamp)

Set cookie's expiration time

setPath(string $location)

Set cookie's path

setDomain(string $domain)

Set cookie's domain

setSecure(bool $mode = true)

Set if the cookie should be transmitted only via https

setHttponly($mode = true)

Set if cookie should be available only to HTTP protocol

boolean
save()

Set cookie

load()

Get cookie

bool
delete()

Delete cookie

bool
exists()

Check if cookie exists

static boolean
erase(string $name)

Static method to quickly delete a cookie

Details

__construct(string $name, int $max_cookie_size = null)

Default cookie's constructor

Parameters

string $name
int $max_cookie_size

Exceptions

CookieException

CookieInterface setName(string $name)

Set cookie name

Parameters

string $name The cookie name.

Return Value

CookieInterface The invoked object.

Exceptions

CookieException

string getName()

Get cookie name

Return Value

string Name of cookie

abstract CookieInterface setValue(string $value, bool $serialize)

Set value of cookie

Parameters

string $value The value of cookie.
bool $serialize If true, cookie will be serialized (default)

Return Value

CookieInterface The invoked object.

Exceptions

CookieException

abstract string getValue(bool $unserialize)

Get cookie value

Parameters

bool $unserialize If true, cookie will be unserialized (default)

Return Value

string Value of cookie

CookieInterface setExpire($timestamp)

Set cookie's expiration time

Parameters

$timestamp

Return Value

CookieInterface The invoked object.

Exceptions

CookieException

CookieInterface setPath(string $location)

Set cookie's path

Parameters

string $location

Return Value

CookieInterface The invoked object.

Exceptions

CookieException

CookieInterface setDomain(string $domain)

Set cookie's domain

Parameters

string $domain

Return Value

CookieInterface The invoked object.

Exceptions

CookieException

CookieInterface setSecure(bool $mode = true)

Set if the cookie should be transmitted only via https

Parameters

bool $mode

Return Value

CookieInterface The invoked object.

CookieInterface setHttponly($mode = true)

Set if cookie should be available only to HTTP protocol

Parameters

$mode

Return Value

CookieInterface The invoked object.

boolean save()

Set cookie

Return Value

boolean

CookieInterface load()

Get cookie

Return Value

CookieInterface The invoked object.

bool delete()

Delete cookie

Return Value

bool

bool exists()

Check if cookie exists

Return Value

bool

static boolean erase(string $name)

Static method to quickly delete a cookie

Parameters

string $name The cookie name

Return Value

boolean

Exceptions

CookieException