Package io.mangoo.routing.bindings
Class Session
- java.lang.Object
-
- io.mangoo.routing.bindings.Session
-
public class Session extends Object
- Author:
- svenkubiak
-
-
Constructor Summary
Constructors Constructor Description Session()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the complete sessionstatic Sessioncreate()Stringget(String key)Retrieves a specific value from the sessionStringgetAuthenticity()LocalDateTimegetExpires()Map<String,String>getValues()booleanhasChanges()booleanhasContent()Checks if the session has at least one entryvoidinvalidate()Invalidates the session by sending expiring the client cookiebooleanisInvalid()voidput(String key, String value)Adds a value to the session, overwriting an existing valuevoidremove(String key)Removes a value with a given key from the sessionSessionwithAuthenticity(String authenticity)SessionwithContent(Map<String,String> values)SessionwithExpires(LocalDateTime expires)
-
-
-
Method Detail
-
create
public static Session create()
-
withExpires
public Session withExpires(LocalDateTime expires)
-
invalidate
public void invalidate()
Invalidates the session by sending expiring the client cookie
-
hasContent
public boolean hasContent()
Checks if the session has at least one entry- Returns:
- True if the session has at least one entry, false otherwise
-
get
public String get(String key)
Retrieves a specific value from the session- Parameters:
key- The key- Returns:
- The value or null if none present
-
getExpires
public LocalDateTime getExpires()
- Returns:
- The expire date of the session
-
put
public void put(String key, String value)
Adds a value to the session, overwriting an existing value- Parameters:
key- The key to store the valuevalue- The value to store
-
remove
public void remove(String key)
Removes a value with a given key from the session- Parameters:
key- The key to remove
-
clear
public void clear()
Clears the complete session
-
hasChanges
public boolean hasChanges()
- Returns:
- True if a session values has change, be removed or the session has been cleared, false otherwise
-
isInvalid
public boolean isInvalid()
-
getAuthenticity
public String getAuthenticity()
- Returns:
- The current authenticity token and marks the session as changed
-
-