$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
setAuthProvidersets a cookie (myna_last_provider) that contains the last AuthAdapter used by this user for this application
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 or sub domains that matches path.  Must start with a dot, e,g, “.mynjs.org”
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
httpOnlyDefault true Should this cookie be invisible to browser JavaScript?
secureDefault false Should this cookie only be sent via SSL?  Returns: value

See

setAuthUserId

setAuthUserId:function(user_id,
cookieOptions)

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.

setAuthProvider

setAuthProvider:function(auth_type,
cookieOptions)

sets a cookie (myna_last_provider) that contains the last AuthAdapter used by this user for this application

Parameters

auth_typeprovider name that this user should be re-authenticated with

Returns

void

Detail

this is a plain text AuthType name that can be used with Myna.Permissions.getAuthAdapter

clearAuthUserId

clearAuthUserId:function()

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,
path)

clears a cookie.  Equivalent to $cookie.set(name, “”,{expireSeconds:0}) Parameters: name - name of cookie to delete path - Optional, default null If provided, the cookie on this path will be deleted Returns: void

get:function(name)
returns the value of the named cookie.
set:function(name,
value,
options)
sets a cookie
setAuthUserId:function(user_id,
cookieOptions)
sets a cookie that contains the supplied user_id and a timestamp
setAuthProvider:function(auth_type,
cookieOptions)
sets a cookie (myna_last_provider) that contains the last AuthAdapter used by this user for this application
clearAuthUserId:function()
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,
path)
clears a cookie.
getAuthAdapter:function(auth_type)
creates and configures and authentication adapter based on the auth type name provided