Class: Session

vertx-apex-js/session~ Session

new Session()

Represents a browser session.

Sessions persist between HTTP requests for a single browser session. They are deleted when the browser is closed, or they time-out. Session cookies are used to maintain sessions using a secure UUID.

Sessions can be used to maintain data for a browser session, e.g. a shopping basket.

Source:

Methods

destroy()

Destroy the session
Source:

get(key) → {Object}

Get some data from the session
Parameters:
Name Type Description
key string the key of the data
Source:
Returns:
the data
Type
Object

getPrincipal() → {Object}

Get the principal
Source:
Returns:
the principal or null if not logged in
Type
Object

hasPermission(permission, resultHandler)

Does the logged in user have the specified permissions? Information is cached for the lifetime of the session
Parameters:
Name Type Description
permission string the permission
resultHandler function will be called with a result true/false
Source:

hasPermissions(permissions, resultHandler)

Does the logged in user have the specified permissions? Information is cached for the lifetime of the session
Parameters:
Name Type Description
permissions Array.<string> the permissions
resultHandler function will be called with a result true/false
Source:

hasRole(role, resultHandler)

Does the logged in user have the specified role? Information is cached for the lifetime of the session
Parameters:
Name Type Description
role string the role
resultHandler function will be called with a result true/false
Source:

hasRoles(roles, resultHandler)

Does the logged in user have the specified roles? Information is cached for the lifetime of the session
Parameters:
Name Type Description
roles Array.<string> the roles
resultHandler function will be called with a result true/false
Source:

id() → {string}

Source:
Returns:
  • The unique ID of the session. This is generated using a random secure UUID.
  • Type
    string

isDestroyed() → {boolean}

Source:
Returns:
  • has the session been destroyed?
  • Type
    boolean

isLoggedIn() → {boolean}

Source:
Returns:
  • true if the user is logged in.
  • Type
    boolean

lastAccessed() → {number}

Source:
Returns:
  • the time the session was last accessed
  • Type
    number

logout()

Logout the user.
Source:

put(key, obj) → {Session}

Put some data in a session
Parameters:
Name Type Description
key string the key for the data
obj Object the data
Source:
Returns:
a reference to this, so the API can be used fluently
Type
Session

remove(key) → {Object}

Remove some data from the session
Parameters:
Name Type Description
key string the key of the data
Source:
Returns:
the data that was there or null if none there
Type
Object

sessionStore() → {SessionStore}

Source:
Returns:
  • the store for the session
  • Type
    SessionStore

setAccessed()

Mark the session as being accessed.
Source:

setAuthProvider(authProvider)

Set the auth provider
Parameters:
Name Type Description
authProvider AuthProvider the auth provider
Source:

setPrincipal(principal)

Set the principal (the unique user id) of the user -this signifies the user is logged in
Parameters:
Name Type Description
principal Object the principal
Source:

timeout() → {number}

Source:
Returns:
  • the amount of time in ms, after which the session will expire, if not accessed.
  • Type
    number