SignedCookieManager View code

Implements \CMSMS\ICookieManager

This cookie manager obfuscates all keys and signs via SHA1 the values On get, if the attached signature does not match the generated signature, no value is returned.

since 2.3
package

CMS

licwnse

2.3

author

Robert Campbell

Methods

__construct(\CmsApp $app) 

Constructor.

Arguments

\CmsApp $app

The application instance.

get_key(string $key) 

Encode a key.

The cookie name is encoded to be obfuscated to minimize the opportunity of attacks.

Arguments

string $key

The cookie name

get(string $okey) : string|null

Retrieve the value of a cookie.

This method will retrieve the value of the cookie by first obfuscating the cookie name. Then ensuring that the signature of retrieved cookie can be verified.

Arguments

string $okey

The cookie name

Response

string|null

set(string $okey, string $value, integer $expires) : boolean

Set a cookie.

This method will first obfuscate the cookie name. Then it will generate a signature for the cookie contents, then append it to the cookie value. Then generate a standard cookie.

Arguments

string $okey

The input cookie name

string $value

The cookie value.

integer $expires

The expiry timestamp of the cookie. A value of 0 indicates that a session cookie should be created.

Response

boolean

true on success

exists(string $key) : boolean

Test if a cookie exists.

This method will obfuscate the input cookie name.

Arguments

string $key

The input cookie name.

Response

boolean

erase(string $key) 

Erase a cookie.

This method will obfuscate the input cookie name.

Arguments

string $key

The input cookie name.