AutoCookieManager View code

Extends \CMSMS\SignedCookieManager

This class adjusts the way cookies are stored to allow identifying their primitive type (string, object, array). And then when retrieved can automatically restore them.

This class uses json to encoe arrays and objects, for security. Objects should implement the JsonSerializable interface if they can be saved to a cookie.

since 2.3
package

CMS

licwnse

2.3

author

Robert Campbell

Methods

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

Set a cookie.

inherited

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

get(string $okey) : string|null

Retrieve the value of a cookie.

inherited

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

__construct(\CmsApp $app) 

Constructor.

inherited

Arguments

\CmsApp $app

The application instance.

get_key(string $key) 

Encode a key.

inherited

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

Arguments

string $key

The cookie name

exists(string $key) : boolean

Test if a cookie exists.

inherited

This method will obfuscate the input cookie name.

Arguments

string $key

The input cookie name.

Response

boolean

erase(string $key) 

Erase a cookie.

inherited

This method will obfuscate the input cookie name.

Arguments

string $key

The input cookie name.

Constants

KEY_OBJ

KEY_OBJ

KEY_ASSOC

KEY_ASSOC