DATA Methods

cookie()

Reads and writes cookie values. Make sure you have defined a valid cookie-name in the backend's setup section, otherwise this method won't work. The function may also be used with one of the system identifiers shown in the parameters section below.

mixed cookie([ string ident [, mixed value ]])

Return

Returns string type cookie value. If no identifier was passed the function will return an array containing all cookie values.

Parameter
Description
identName of variable for which the values is to be stored. If no identifier is passed, function will return array containing all cookie values. You may also use one of these system-identifiers to retrieve further information about the cookie

SYS_COOKIE_ACT: check if user allows cookies
SYS_COOKIE_AGE: cookie's age in seconds
SYS_COOKIE_DEL: delete all cookie information
SYS_COOKIE_IDX: ID that corresponds with the time the cookie was created

These system-identifiers will only work the second time the page has been called, since the cookie will be created upon the first visit of the page. All system-values are read-only!!
valueValue to be stored in cookie. If no value is passed function will return current cookie value. Do not try to store an array as a cookie value.

Set cookie value

$DATA->cookie('testvalue', 123)
RETURN: '123'

Read cookie value

$DATA->cookie('testvalue')
RETURN: '123'

Set another cookie value

$DATA->cookie('anothertest', true)
RETURN: '1'

Return all cookie values

$DATA->cookie()
RETURN: ARRAY [2]

Check if cookies are activated

$DATA->cookie(SYS_COOKIE_ACT)
RETURN: FALSE

Return cookie index

$DATA->cookie(SYS_COOKIE_IDX)
RETURN: '1713937389'

Return cookie age

$DATA->cookie(SYS_COOKIE_AGE)
RETURN: 0