class EncryptedCookie extends AbstractCookie (View source)

AES-encrypted cookie

Properties

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

Methods

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

Encrypted cookie constructor

setName(string $name)

Set cookie name

string
getName()

Get cookie name

setValue(string $value, bool $serialize = true)

Set value of cookie

string
getValue(bool $unserialize = true)

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

static EncryptedCookie
create($name, $key, array $properties = [], $serialize = true)

Static method to quickly create a cookie

static EncryptedCookie
retrieve(string $name, string $key)

Static method to quickly get a cookie

static string
encryptKey(string $key)

Hash the key to generate a valid aes key value

Details

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

Encrypted cookie constructor

Setup cookie name and key

Parameters

string $name
string $key
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

CookieInterface setValue(string $value, bool $serialize = true)

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

string getValue(bool $unserialize = true)

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

static EncryptedCookie create($name, $key, array $properties = [], $serialize = true)

Static method to quickly create a cookie

Parameters

$name
$key
array $properties
$serialize

Return Value

EncryptedCookie

Exceptions

CookieException

static EncryptedCookie retrieve(string $name, string $key)

Static method to quickly get a cookie

Parameters

string $name The cookie name
string $key

Return Value

EncryptedCookie

Exceptions

CookieException

static protected string encryptKey(string $key)

Hash the key to generate a valid aes key value

Parameters

string $key

Return Value

string