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

### Methods

#### destroy()

Destroy the session

Source:
  - vertx-web-js/session.js, line 128

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

Get some data from the session

##### Parameters:

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

Source:
  - vertx-web-js/session.js, line 88

##### Returns:

the data

Type
  Object

#### id() → {string}

Source:
  - vertx-web-js/session.js, line 58

##### Returns:

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

Type
  string

#### isDestroyed() → {boolean}

Source:
  - vertx-web-js/session.js, line 141

##### Returns:

has the session been destroyed?

Type
  boolean

#### isRegenerated() → {boolean}

Source:
  - vertx-web-js/session.js, line 154

##### Returns:

has the session been renewed?

Type
  boolean

#### lastAccessed() → {number}

Source:
  - vertx-web-js/session.js, line 115

##### Returns:

the time the session was last accessed

Type
  number

#### oldId() → {string}

Source:
  - vertx-web-js/session.js, line 167

##### Returns:

old ID if renewed

Type
  string

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

##### Returns:

a reference to this, so the API can be used fluently

Type
  Session

#### regenerateId() → {Session}

Source:
  - vertx-web-js/session.js, line 45

##### Returns:

The new unique ID of the session.

Type
  Session

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

Remove some data from the session

##### Parameters:

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

Source:
  - vertx-web-js/session.js, line 102

##### Returns:

the data that was there or null if none there

Type
  Object

#### setAccessed()

Mark the session as being accessed.

Source:
  - vertx-web-js/session.js, line 193

#### timeout() → {number}

Source:
  - vertx-web-js/session.js, line 180

##### Returns:

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

Type
  number