public interface Session
Modifier and Type | Field and Description |
---|---|
static String |
AUTHENTICITY_KEY |
static String |
EXPIRY_TIME_KEY |
static String |
ID_KEY |
static String |
TIMESTAMP_KEY |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all values from the session.
|
String |
get(String key)
Returns the value of the key or null.
|
String |
getAuthenticityToken() |
Map<String,String> |
getData() |
String |
getId() |
void |
init(Context context)
Has to be called initially.
|
boolean |
isEmpty()
Returns true if the session is empty, e.g.
|
void |
put(String key,
String value)
Puts key / value into the session.
|
String |
remove(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(Long expiryTimeMs)
Use an alternative expiry time, this can be used to implement a longer
expiry time for 'remember me' style functionality.
|
static final String AUTHENTICITY_KEY
static final String ID_KEY
static final String TIMESTAMP_KEY
static final String EXPIRY_TIME_KEY
void init(Context context)
context
- The context of this session.String getId()
String getAuthenticityToken()
void save(Context context)
context
- The context from where to deduct a potentially existing session.void put(String key, String value)
key
- Name of the key to store in the session.value
- The value to store in the sessionString get(String key)
key
- Name of the key to retrieve.String remove(String key)
key
- name of the key to removevoid clear()
boolean isEmpty()
void setExpiryTime(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 © 2019 ninjaframework. All rights reserved.