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 (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `void` | `destroy()` Destroy the session
    `T` | `get(java.lang.String key)` Get some data from the session
    `java.lang.Object` | `getDelegate()`
    `java.lang.String` | `id()` Returns: The unique ID of the session.
    `boolean` | `isDestroyed()` @return has the session been destroyed?
    `long` | `lastAccessed()` @return the time the session was last accessed
    `Session` | `put(java.lang.String key, java.lang.Object obj)` Put some data in a session
    `T` | `remove(java.lang.String key)` Remove some data from the session
    `void` | `setAccessed()` Mark the session as being accessed.
    `long` | `timeout()` @return 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 java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### Session(java.lang.Object delegate)

  - ### Method Detail

    - #### void destroy()

      Destroy the session

    - #### T get(java.lang.String key)

      Get some data from the session

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

    - #### java.lang.Object getDelegate()

    - #### java.lang.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(java.lang.String key, java.lang.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(java.lang.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.