Module io.jooby
Package io.jooby

Interface Session


public interface Session
HTTP session. Only basic data types can be saved into session.
Since:
2.0.0
Author:
edgar
  • Field Details

  • Method Details

    • getId

      @Nullable String getId()
      Session ID or null for stateless (usually signed) sessions.
      Returns:
      Session ID or null for stateless (usually signed) sessions.
    • setId

      @NonNull Session setId(@Nullable String id)
      Set Session ID.
      Parameters:
      id - Session ID or null
      Returns:
      Session.
    • get

      @NonNull Value get(@NonNull String name)
      Get a session attribute.
      Parameters:
      name - Attribute's name.
      Returns:
      An attribute value or missing value.
    • put

      @NonNull default Session put(@NonNull String name, int value)
      Put a session attribute.
      Parameters:
      name - Attribute's name.
      value - Attribute's value.
      Returns:
      This session.
    • put

      @NonNull default Session put(@NonNull String name, long value)
      Put a session attribute.
      Parameters:
      name - Attribute's name.
      value - Attribute's value.
      Returns:
      This session.
    • put

      @NonNull default Session put(@NonNull String name, @NonNull CharSequence value)
      Put a session attribute.
      Parameters:
      name - Attribute's name.
      value - Attribute's value.
      Returns:
      This session.
    • put

      @NonNull Session put(@NonNull String name, @NonNull String value)
      Put a session attribute.
      Parameters:
      name - Attribute's name.
      value - Attribute's value.
      Returns:
      This session.
    • put

      @NonNull default Session put(@NonNull String name, float value)
      Put a session attribute.
      Parameters:
      name - Attribute's name.
      value - Attribute's value.
      Returns:
      This session.
    • put

      @NonNull default Session put(@NonNull String name, double value)
      Put a session attribute.
      Parameters:
      name - Attribute's name.
      value - Attribute's value.
      Returns:
      This session.
    • put

      @NonNull default Session put(@NonNull String name, boolean value)
      Put a session attribute.
      Parameters:
      name - Attribute's name.
      value - Attribute's value.
      Returns:
      This session.
    • put

      @NonNull default Session put(@NonNull String name, @NonNull Number value)
      Put a session attribute.
      Parameters:
      name - Attribute's name.
      value - Attribute's value.
      Returns:
      This session.
    • remove

      @NonNull Value remove(@NonNull String name)
      Remove a session attribute.
      Parameters:
      name - Attribute's name.
      Returns:
      Session attribute or missing value.
    • toMap

      @NonNull Map<String,String> toMap()
      Read-only copy of session attributes.
      Returns:
      Read-only attributes.
    • getCreationTime

      @NonNull Instant getCreationTime()
      Session creation time.
      Returns:
      Session creation time.
    • setCreationTime

      @NonNull Session setCreationTime(@NonNull Instant creationTime)
      Set session creation time.
      Parameters:
      creationTime - Session creation time.
      Returns:
      This session.
    • getLastAccessedTime

      @NonNull Instant getLastAccessedTime()
      Session last accessed time.
      Returns:
      Session creation time.
    • setLastAccessedTime

      @NonNull Session setLastAccessedTime(@NonNull Instant lastAccessedTime)
      Set session last accessed time.
      Parameters:
      lastAccessedTime - Session creation time.
      Returns:
      This session.
    • isNew

      boolean isNew()
      True for new sessions.
      Returns:
      True for new sessions.
    • setNew

      @NonNull Session setNew(boolean isNew)
      Set new flag. This method is part of public API but shouldn't be use it.
      Parameters:
      isNew - New flag.
      Returns:
      This session.
    • isModify

      boolean isModify()
      True for modified/dirty sessions.
      Returns:
      True for modified/dirty sessions.
    • setModify

      @NonNull Session setModify(boolean modify)
      Set modify flag. This method is part of public API but shouldn't be use it.
      Parameters:
      modify - Modify flag.
      Returns:
      This session.
    • clear

      Session clear()
      Remove all attributes.
      Returns:
      This session.
    • destroy

      void destroy()
      Destroy/invalidates this session.
    • renewId

      Session renewId()
      Assign a new ID to the existing session.
      Returns:
      This session.
    • create

      @NonNull static Session create(@NonNull Context ctx, @Nullable String id)
      Creates a new session.
      Parameters:
      ctx - Web context.
      id - Session ID or null.
      Returns:
      A new session.
    • create

      @NonNull static Session create(@NonNull Context ctx, @Nullable String id, @NonNull Map<String,String> data)
      Creates a new session.
      Parameters:
      ctx - Web context.
      id - Session ID or null.
      data - Session attributes.
      Returns:
      A new session.