RdbAdmin Module

Cookie
in package

Cookie class.

Tags
since
0.1

Table of Contents

Properties

$Container  : Container
$hashConfigModule  : string
$hashConfigName  : string

Methods

__construct()  : mixed
Class constructor.
get()  : mixed
Get a cookie value.
set()  : bool
Set a cookie.
setEncryption()  : mixed
Mark that this cookie must use encryption.

Properties

$Container

protected Container $Container

$hashConfigModule

protected string $hashConfigModule

The module name that this hash configuration file stored in.

$hashConfigName

protected string $hashConfigName

Hash configuration name that will be found in config/hash.php in the module.

Methods

__construct()

Class constructor.

public __construct(Container $Container) : mixed
Parameters
$Container : Container

The DI container.

get()

Get a cookie value.

public get(string $name[, mixed $default = null ]) : mixed

If you want to use encrypted cookie then call to setEncryption() method before.
The cookie value can be any format such as string, array, object, etc. depend on how it was set.

Parameters
$name : string

The name of the cookie.

$default : mixed = null

The value of cookie.

Return values
mixed

Return value of cookie. The type is depend on how it was set.

set()

Set a cookie.

public set(string $name[, mixed $value = '' ][, int $expires = 0 ][, string $path = '' ][, string $domain = '' ][, bool $secure = false ][, bool $httponly = false ]) : bool

If you want to use encrypted cookie then call to setEncryption() method before.
The cookie value can be any format such as string, array, object, etc.

Parameters
$name : string

The name of the cookie.

$value : mixed = ''

The value of the cookie. If it is not scalar then it will be serialize before.

$expires : int = 0

The time the cookie expires. This is a Unix timestamp so is in number of seconds since the epoch. In other words, you'll most likely set this with the time() function plus the number of seconds before you want it to expire.

$path : string = ''

The path on the server in which the cookie will be available on. If set to '/', the cookie will be available within the entire domain.

$domain : string = ''

The (sub)domain that the cookie is available to.

$secure : bool = false

Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client.

$httponly : bool = false

When true the cookie will be made accessible only through the HTTP protocol.

Tags
link

setcookie() function reference.

see
setcookie()
Return values
bool

If output exists prior to calling this function, setcookie() will fail and return false. If setcookie() successfully runs, it will return true. This does not indicate whether the user accepted the cookie.

setEncryption()

Mark that this cookie must use encryption.

public setEncryption(string $hashConfigName[, string $hashConfigModule = 'RdbAdmin' ]) : mixed

If do not use encryption then set $hashConfigName to null.

Parameters
$hashConfigName : string

Hash configuration name that will be found in config/hash.php in the module.

$hashConfigModule : string = 'RdbAdmin'

The module name that this hash configuration file stored in.


        
On this page

Search results