public interface Session extends MutableConvertibleValues<java.lang.Object>
An interface representing a user session.
EMPTY
Modifier and Type | Method and Description |
---|---|
default java.util.Optional<java.lang.Object> |
get(java.lang.CharSequence attr)
Retrieve an attribute for the given name.
|
java.time.Instant |
getCreationTime()
Returns the time when this session was created.
|
java.lang.String |
getId()
A unique identifier for the session.
|
java.time.Instant |
getLastAccessedTime()
Returns the last time the client sent a request associated with this session as an
Instant . |
java.time.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(java.time.Instant instant)
Sets the last accessed time on the session.
|
Session |
setMaxInactiveInterval(java.time.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
@NonNull java.time.Instant getCreationTime()
Instant
instancejava.lang.IllegalStateException
- if this method is called on an invalidated session@NonNull java.lang.String getId()
@NonNull java.time.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 accessedjava.lang.IllegalStateException
- if this method is called on an invalidated sessionSession setLastAccessedTime(java.time.Instant instant)
instant
- The instant that represents the last accessed timeSession setMaxInactiveInterval(java.time.Duration duration)
duration
- A duration specifying the max inactive intervaljava.time.Duration 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 java.util.Optional<java.lang.Object> get(java.lang.CharSequence attr)
attr
- The attribute nameOptional
of the attributedefault boolean isExpired()