public interface Session
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUTHENTICITY_KEY |
static java.lang.String |
EXPIRY_TIME_KEY |
static java.lang.String |
ID_KEY |
static java.lang.String |
TIMESTAMP_KEY |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all values from the session.
|
java.lang.String |
get(java.lang.String key)
Returns the value of the key or null.
|
java.lang.String |
getAuthenticityToken() |
java.util.Map<java.lang.String,java.lang.String> |
getData() |
java.lang.String |
getId() |
void |
init(Context context)
Has to be called initially.
|
boolean |
isEmpty()
Returns true if the session is empty, e.g.
|
void |
put(java.lang.String key,
java.lang.String value)
Puts key / value into the session.
|
java.lang.String |
remove(java.lang.String key)
Removes the value of the key and returns the value or null.
|
void |
save(Context context)
To finally send this session to the user this method has to be called.
|
void |
setExpiryTime(java.lang.Long expiryTimeMs)
Use an alternative expiry time, this can be used to implement a longer
expiry time for 'remember me' style functionality.
|
static final java.lang.String AUTHENTICITY_KEY
static final java.lang.String ID_KEY
static final java.lang.String TIMESTAMP_KEY
static final java.lang.String EXPIRY_TIME_KEY
void init(Context context)
context
- The context of this session.java.lang.String getId()
java.util.Map<java.lang.String,java.lang.String> getData()
java.lang.String getAuthenticityToken()
void save(Context context)
context
- The context from where to deduct a potentially existing session.void put(java.lang.String key, java.lang.String value)
key
- Name of the key to store in the session.value
- The value to store in the sessionjava.lang.String get(java.lang.String key)
key
- Name of the key to retrieve.java.lang.String remove(java.lang.String key)
key
- name of the key to removevoid clear()
boolean isEmpty()
void setExpiryTime(java.lang.Long expiryTimeMs)
expiryTimeMs
- the expiry time in milliseconds, set to null to remove
the expiry time from the session and use the application
default.Copyright © 2016 ninjaframework. All Rights Reserved.