$cookie

A global object for interacting with cookies in the current request

Summary
$cookieA global object for interacting with cookies in the current request
Properties
dataArray of javax.servlet.http.Cookie objects sent in this request.
Functions
getreturns the value of the named cookie.
setsets a cookie
setAuthUserIdsets a cookie that contains the supplied user_id and a timestamp
clearAuthUserIdClears the “myna_auth_cookie”.
getAuthUserIdReturns the user_id in “myna_auth_cookie”, or null if there is no cookie
getAuthUserReturn the result of Myna.Permissions.getUserById for the user_id in “myna_auth_cookie”, or null if there is no cookie
clearclears a cookie.

Properties

data

Array of javax.servlet.http.Cookie objects sent in this request.

Functions

get

get:function(name)

returns the value of the named cookie.

Parameters

nameName of cookie to retrieve

Returns

The value of the named cookie or null if not defined.

set

set:function(name,
value,
options)

sets a cookie

Parameters

nameName of cookie to set
valueString value of cookie
optionsOptional JavaScript Object of extra optional parameters.  See below:

Options

domainDefault null Domain to share the cookie with.  If set, the browser will send this cookie to any page in this domain that matches path.
pathDefault null Start path of page that the cookie should be sent to.
expireSecondsDefault -1 An integer specifying the maximum age of the cookie in seconds; if negative, means the cookie is not stored; if zero, deletes the cookie

Returns

void

setAuthUserId

setAuthUserId:function(user_id)

sets a cookie that contains the supplied user_id and a timestamp

Parameters

user_iduser_id of the user to track

Returns

void

Detail

This function sets an encrypted cookie “myna_auth_cookie” that contains the supplied user_id.  Once set, this cookie will be refreshed on every request until cleared with $cookie.clearAuthUserId.

This functionality can bee used as an alternative to sessions.

To access the contents of this cookie, call $cookie.getAuthUser, which will return the result of Myna.Permissions.getUserById for the user_id in the cookie, or null if there is no cookie.

clearAuthUserId

clearAuthUserId:function(name)

Clears the “myna_auth_cookie”.  Equivalent to $cookie.clear(“myna_auth_cookie”)

Returns

void

getAuthUserId

getAuthUserId:function()

Returns the user_id in “myna_auth_cookie”, or null if there is no cookie

Returns

void

getAuthUser

getAuthUser:function()

Return the result of Myna.Permissions.getUserById for the user_id in “myna_auth_cookie”, or null if there is no cookie

Returns

void

clear

clear:function(name)

clears a cookie.  Equivalent to $cookie.set(name, “”,{expireSeconds:0})

Returns

void

get:function(name)
returns the value of the named cookie.
set:function(name,
value,
options)
sets a cookie
setAuthUserId:function(user_id)
sets a cookie that contains the supplied user_id and a timestamp
clearAuthUserId:function(name)
Clears the “myna_auth_cookie”.
getAuthUserId:function()
Returns the user_id in “myna_auth_cookie”, or null if there is no cookie
getAuthUser:function()
Return the result of Myna.Permissions.getUserById for the user_id in “myna_auth_cookie”, or null if there is no cookie
getUserById:function(id)
returns the User object that matches the supplied id or null
clear:function(name)
clears a cookie.