java.lang.Object
org.glassfish.grizzly.http.server.Session

public class Session extends Object
Simple session object.
Author:
Jeanfrancois Arcand
  • Constructor Details

    • Session

      public Session()
    • Session

      public Session(String id)
      Create a new session using a session identifier
      Parameters:
      id - session identifier
  • Method Details

    • isValid

      public boolean isValid()
      Is the current Session valid?
      Returns:
      true if valid.
    • setValid

      public void setValid(boolean isValid)
      Set this object as validated.
      Parameters:
      isValid -
    • isNew

      public boolean isNew()
      Returns true if the client does not yet know about the session or if the client chooses not to join the session. For example, if the server used only cookie-based sessions, and the client had disabled the use of cookies, then a session would be new on each request.
      Returns:
      true if the server has created a session, but the client has not yet joined
    • getIdInternal

      public String getIdInternal()
      Returns:
      the session identifier for this session.
    • setIdInternal

      protected void setIdInternal(String id)
      Sets the session identifier for this session.
      Parameters:
      id -
    • setAttribute

      public void setAttribute(String key, Object value)
      Add an attribute to this session.
      Parameters:
      key -
      value -
    • getAttribute

      public Object getAttribute(String key)
      Return an attribute.
      Parameters:
      key -
      Returns:
      an attribute
    • removeAttribute

      public Object removeAttribute(String key)
      Remove an attribute.
      Parameters:
      key -
      Returns:
      true if successful.
    • attributes

      public ConcurrentMap<String,Object> attributes()
      Return a ConcurrentMap of attributes.
      Returns:
      the attributes associated with this session.
    • getCreationTime

      public long getCreationTime()
      Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.
      Returns:
      a long specifying when this session was created, expressed in milliseconds since 1/1/1970 GMT
    • getSessionTimeout

      public long getSessionTimeout()
      Return a long representing the maximum idle time (in milliseconds) a session can be.
      Returns:
      a long representing the maximum idle time (in milliseconds) a session can be.
    • setSessionTimeout

      public void setSessionTimeout(long sessionTimeout)
      Set a long representing the maximum idle time (in milliseconds) a session can be.
      Parameters:
      sessionTimeout - a long representing the maximum idle time (in milliseconds) a session can be.
    • getTimestamp

      public long getTimestamp()
      Returns:
      the timestamp when this session was accessed the last time
    • setTimestamp

      public void setTimestamp(long timestamp)
      Set the timestamp when this session was accessed the last time.
      Parameters:
      timestamp - a long representing when the session was accessed the last time
    • access

      public long access()
      Updates the "last accessed" timestamp with the current time.
      Returns:
      the time stamp