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

getLoginID() → {string}

Source:
Returns:
  • the login ID of the logged in user (if any). Must be used in conjunction with a AuthHandler.
  • Type
    string

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:

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:

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:

setAuthService(authService)

Set the auth service
Parameters:
Name Type Description
authService AuthService the auth service
Source:

setLoginID(loginID)

Set the login ID for the session
Parameters:
Name Type Description
loginID string the login ID
Source:

timeout() → {number}

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