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 |
set(string $okey, string $value, integer $expires) : boolean
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.
string $okeyThe input cookie name
string $valueThe cookie value.
integer $expiresThe expiry timestamp of the cookie. A value of 0 indicates that a session cookie should be created.
boolean
true on success
get(string $okey) : string|null
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.
string $okeyThe cookie name
string|null
get_key(string $key)
The cookie name is encoded to be obfuscated to minimize the opportunity of attacks.
string $keyThe cookie name
exists(string $key) : boolean
This method will obfuscate the input cookie name.
string $keyThe input cookie name.
boolean
erase(string $key)
This method will obfuscate the input cookie name.
string $keyThe input cookie name.
KEY_OBJ
KEY_ASSOC