# Class: Session

## vertx-web-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:
    - session.js, line 34

### Methods

#### destroy()

  Destroy the session
  Source:
    - session.js, line 117

#### get(key) → {Object}

  Get some data from the session

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `key` | string | the key of the data

  Source:
    - session.js, line 76

  ##### Returns:

  the data
  Type
    Object

#### id() → {string}

  Source:
    - session.js, line 46

  ##### Returns:

  - The unique ID of the session. This is generated using a random secure UUID.
  - Type
      string

#### isDestroyed() → {boolean}

  Source:
    - session.js, line 131

  ##### Returns:

  - has the session been destroyed?
  - Type
      boolean

#### lastAccessed() → {number}

  Source:
    - session.js, line 104

  ##### Returns:

  - the time the session was last accessed
  - Type
      number

#### 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:
    - session.js, line 61

  ##### 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:
    - session.js, line 90

  ##### Returns:

  the data that was there or null if none there
  Type
    Object

#### setAccessed()

  Mark the session as being accessed.
  Source:
    - session.js, line 158

#### timeout() → {number}

  Source:
    - session.js, line 145

  ##### Returns:

  - the amount of time in ms, after which the session will expire, if not accessed.
  - Type
      number