public interface Session
HTTP session. Only basic data types can be saved into session.
- Since:
- 2.0.0
- Author:
- edgar
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionclear()
Remove all attributes.static Session
Creates a new session.static Session
Creates a new session.void
destroy()
Destroy/invalidates this session.Get a session attribute.Session creation time.getId()
Session ID ornull
for stateless (usually signed) sessions.Session last accessed time.boolean
isModify()
True for modified/dirty sessions.boolean
isNew()
True for new sessions.default Session
Put a session attribute.default Session
Put a session attribute.default Session
Put a session attribute.default Session
Put a session attribute.default Session
Put a session attribute.default Session
put
(String name, CharSequence value) Put a session attribute.default Session
Put a session attribute.Put a session attribute.Remove a session attribute.renewId()
Assign a new ID to the existing session.setCreationTime
(Instant creationTime) Set session creation time.Set Session ID.setLastAccessedTime
(Instant lastAccessedTime) Set session last accessed time.setModify
(boolean modify) Set modify flag.setNew
(boolean isNew) Set new flag.toMap()
Read-only copy of session attributes.
-
Field Details
-
NAME
Attribute's name.- See Also:
-
-
Method Details
-
getId
Session ID ornull
for stateless (usually signed) sessions.- Returns:
- Session ID or
null
for stateless (usually signed) sessions.
-
setId
Set Session ID.- Parameters:
id
- Session ID ornull
- Returns:
- Session.
-
get
Get a session attribute.- Parameters:
name
- Attribute's name.- Returns:
- An attribute value or missing value.
-
put
Put a session attribute.- Parameters:
name
- Attribute's name.value
- Attribute's value.- Returns:
- This session.
-
put
Put a session attribute.- Parameters:
name
- Attribute's name.value
- Attribute's value.- Returns:
- This session.
-
put
Put a session attribute.- Parameters:
name
- Attribute's name.value
- Attribute's value.- Returns:
- This session.
-
put
Put a session attribute.- Parameters:
name
- Attribute's name.value
- Attribute's value.- Returns:
- This session.
-
put
Put a session attribute.- Parameters:
name
- Attribute's name.value
- Attribute's value.- Returns:
- This session.
-
put
Put a session attribute.- Parameters:
name
- Attribute's name.value
- Attribute's value.- Returns:
- This session.
-
put
Put a session attribute.- Parameters:
name
- Attribute's name.value
- Attribute's value.- Returns:
- This session.
-
put
Put a session attribute.- Parameters:
name
- Attribute's name.value
- Attribute's value.- Returns:
- This session.
-
remove
Remove a session attribute.- Parameters:
name
- Attribute's name.- Returns:
- Session attribute or missing value.
-
toMap
Read-only copy of session attributes.- Returns:
- Read-only attributes.
-
getCreationTime
Session creation time.- Returns:
- Session creation time.
-
setCreationTime
Set session creation time.- Parameters:
creationTime
- Session creation time.- Returns:
- This session.
-
getLastAccessedTime
Session last accessed time.- Returns:
- Session creation time.
-
setLastAccessedTime
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
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
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
Creates a new session.- Parameters:
ctx
- Web context.id
- Session ID ornull
.- 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 ornull
.data
- Session attributes.- Returns:
- A new session.
-