public interface Session extends MutableConvertibleValues<Object>
An interface representing a user session.
EMPTY
Modifier and Type | Method and Description |
---|---|
default Optional<Object> |
get(CharSequence attr)
Retrieve an attribute for the given name.
|
Instant |
getCreationTime()
Returns the time when this session was created.
|
String |
getId()
A unique identifier for the session.
|
Instant |
getLastAccessedTime()
Returns the last time the client sent a request associated with this session as an
Instant . |
Duration |
getMaxInactiveInterval()
Returns the maximum time interval as a
Duration that sessions will be kept open between client accesses. |
default boolean |
isExpired() |
boolean |
isModified() |
boolean |
isNew() |
Session |
setLastAccessedTime(Instant instant)
Sets the last accessed time on the session.
|
Session |
setMaxInactiveInterval(Duration duration)
Specifies the duration between client requests before session should be invalidated.
|
clear, of, put, putAll, putAll, remove
asMap, asMap, asProperties, contains, empty, forEach, getValue, getValueType, isEmpty, iterator, names, subMap, subMap, subMap, values
get, get, get, get
forEach, spliterator
@NonNull Instant getCreationTime()
Instant
instanceIllegalStateException
- if this method is called on an invalidated session@NonNull Instant getLastAccessedTime()
Instant
.
Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.
Instant
representing the time the session was last accessedIllegalStateException
- if this method is called on an invalidated sessionSession setLastAccessedTime(Instant instant)
instant
- The instant that represents the last accessed timeSession setMaxInactiveInterval(Duration duration)
duration
- A duration specifying the max inactive intervalDuration getMaxInactiveInterval()
Duration
that sessions will be kept open between client accesses.
After this interval, the servlet container will invalidate the session. The maximum time interval can be set
with the setMaxInactiveInterval
method.setMaxInactiveInterval(java.time.Duration)
boolean isNew()
boolean isModified()
default Optional<Object> get(CharSequence attr)
attr
- The attribute nameOptional
of the attributedefault boolean isExpired()