Package org.zkoss.zk.ui

## Interface Session

- All Superinterfaces:
    `Scope`
  All Known Implementing Classes:
    `SerializableSession`, `SimpleSession`

      public interface Session
      extends Scope

  A user session.

  To get the current session, use `Sessions.getCurrent()`, or `Desktop.getSession()`.

  A session, `Session`, might have multiple pages, `Page`, while a page belongs to exactly one session. A page, `Page`, might have many components, `Component`, while a component belongs to exactly one page.

  Author:
    tomyeh

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `java.lang.Object` | `getAttribute​(java.lang.String name)` | Returns the value of the specified custom attribute.
    `java.util.Map<java.lang.String,​java.lang.Object>` | `getAttributes()` | Returns a map of custom attributes associated with this session.
    `java.lang.String` | `getDeviceType()` | Returns the device type that this session belongs to.
    `int` | `getMaxInactiveInterval()` | Return the time, in seconds, between client requests before the servlet container will invalidate this session.
    `java.lang.Object` | `getNativeSession()` | Returns the native session, or null if not available.
    `WebApp` | `getWebApp()` | Returns the Web application that this session belongs to.
    `void` | `invalidate()` | Invalidates this session then unbinds any objects bound to it.
    `java.lang.Object` | `removeAttribute​(java.lang.String name)` | Removes the specified custom attribute.
    `java.lang.Object` | `setAttribute​(java.lang.String name, java.lang.Object value)` | Sets the value of the specified custom attribute.
    `void` | `setMaxInactiveInterval​(int interval)` | Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.

    - ### Methods inherited from interface org.zkoss.zk.ui.ext.Scope

      `addScopeListener, getAttribute, hasAttribute, hasAttribute, removeAttribute, removeScopeListener, setAttribute`

- - ### Method Detail

    - #### getDeviceType

          java.lang.String getDeviceType()

      Returns the device type that this session belongs to.

      A device type identifies the type of a client. For example, "ajax" represents the Web browsers with Ajax support, while "mil" represents clients that supports Mobile Interactive markup Language (on Limited Connected Device, such as mobile phones).

      All desktops of the same session must belong to the same device type.

      The session's device type is determined by the first desktop's device type.

      Since:
        2.4.1

    - #### getAttribute

          java.lang.Object getAttribute​(java.lang.String name)

      Returns the value of the specified custom attribute.
      Specified by:
        `getAttribute` in interface `Scope`

    - #### setAttribute

          java.lang.Object setAttribute​(java.lang.String name,
                                        java.lang.Object value)

      Sets the value of the specified custom attribute.
      Specified by:
        `setAttribute` in interface `Scope`
      Returns:
        the previous value if any (since ZK 5)

    - #### removeAttribute

          java.lang.Object removeAttribute​(java.lang.String name)

      Removes the specified custom attribute.
      Specified by:
        `removeAttribute` in interface `Scope`
      Returns:
        the previous value if any (since ZK 5)

    - #### getAttributes

          java.util.Map<java.lang.String,​java.lang.Object> getAttributes()

      Returns a map of custom attributes associated with this session.
      Specified by:
        `getAttributes` in interface `Scope`

    - #### getWebApp

          WebApp getWebApp()

      Returns the Web application that this session belongs to.

    - #### invalidate

          void invalidate()

      Invalidates this session then unbinds any objects bound to it.

      Note: you usually have to ask the client to redirect to another page (or reload the same page) by use of `Executions.sendRedirect(java.lang.String)`.

      The session is not invalidated immediately. Rather, it is invalidated after processing the current request.

    - #### setMaxInactiveInterval

          void setMaxInactiveInterval​(int interval)

      Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. A negative time indicates the session should never timeout.
      See Also:
        `Configuration.setTimerKeepAlive(boolean)`, `Configuration.setSessionMaxInactiveInterval(int)`

    - #### getMaxInactiveInterval

          int getMaxInactiveInterval()

      Return the time, in seconds, between client requests before the servlet container will invalidate this session. A negative time indicates the session should never timeout.
      Since:
        3.0.0
      See Also:
        `Configuration.isTimerKeepAlive()`, `Configuration.getSessionMaxInactiveInterval()`

    - #### getNativeSession

          java.lang.Object getNativeSession()

      Returns the native session, or null if not available. The returned object depends on the type of clients. If HTTP, the object is an instance of javax.servlet.http.HttpSession. If portlet, the object is an instance of javax.portlet.PortletSession.