Package: io.vertx.groovy.ext.web

## [Groovy] Class Session

- io.vertx.groovy.ext.web.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.

  The context must have first been routed to a SessionHandler for sessions to be available.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `Session (Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `void` | `destroy()` Destroy the session
    `T` | `get(String key)` Get some data from the session
    `Object` | `getDelegate()`
    `String` | `id()` Returns: The unique ID of the session.
    `boolean` | `isDestroyed()` Returns: has the session been destroyed?
    `long` | `lastAccessed()` @return Returns: the time the session was last accessed
    `Session` | `put(String key, Object obj)` Put some data in a session
    `T` | `remove(String key)` Remove some data from the session
    `void` | `setAccessed()` Mark the session as being accessed.
    `long` | `timeout()` Returns: the amount of time in ms, after which the session will expire, if not accessed.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Constructor Detail

    - #### Session(Object delegate)

  - ### Method Detail

    - #### void destroy()

      Destroy the session

    - #### T get(String key)

      Get some data from the session

      Returns:
        the data
      Parameters:
        `key` - the key of the data

    - #### Object getDelegate()

    - #### String id()

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

    - #### boolean isDestroyed()

      Returns:
        has the session been destroyed?

    - #### long lastAccessed()

      Returns:
        the time the session was last accessed

    - #### Session put(String key, Object obj)

      Put some data in a session

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `key` - the key for the data
        `obj` - the data

    - #### T remove(String key)

      Remove some data from the session

      Returns:
        the data that was there or null if none there
      Parameters:
        `key` - the key of the data

    - #### void setAccessed()

      Mark the session as being accessed.

    - #### long timeout()

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