-
Notifications
You must be signed in to change notification settings - Fork 2
Session
Sessions are implemented using ASP.NET. You can use the session to store and retrieve values.
This class can set, get and remove key-value pairs.
Unlike SessionStorage in browsers, this session allows you to store all types of variables instread of only strings.
functions:
examples:
Sessions.get takes a key, gets the value linked in the session and returns the value.
| Variable | Description |
|---|---|
| key | The key to get a value from |
Returns: Value linked to key.
Exceptions:
- InternalError: Thrown when no application has been found in application scope.
Example:
var value = Sessions.get("userID");Sessions.set takes a key and a value and sets the link in the session.
| Variable | Description |
|---|---|
| key | The key to set a value with |
| value | The value to link to the key |
Exceptions:
- InternalError: Thrown when no application has been found in application scope.
Example:
Session.set("userId", user.id);Sessions.remove takes a key and removes it from the session.
| Variable | Description |
|---|---|
| key | The key to get a value from |
Exceptions:
- InternalError: Thrown when no application has been found in application scope.
Example:
Sessions.remove("userId");Sessions.clear removes all values from the session.
Exceptions:
- InternalError: Thrown when no application has been found in application scope.
Example:
Sessions.clear();Sessions.getAll returns the entire session object.
Returns: Object containing all keys and values.
Exceptions:
- InternalError: Thrown when no application has been found in application scope.
Example:
var session = Sessions.getAll();Here you can see the functions of this class in action:
Sessions.set("key", "value");
console.log(Sessions.get("key"); //prints: value
Sessions.delete("key");