Skip to content

Session

mrvek edited this page May 9, 2018 · 9 revisions

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.

Index

functions:

examples:


Functions

get(key)

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");

set(key,value)

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);

remove(key)

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");

clear()

Sessions.clear removes all values from the session.

Exceptions:

  • InternalError: Thrown when no application has been found in application scope.

Example:

Sessions.clear();

getAll()

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();

Examples

Functions implementation

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");

Home
Getting started
Debugging with Visual Studio Code Documentation
   Core
   Async
   Base64
   Functions
   HTTP
   IO
   Log
   Session
   SQL
   XDoc

   Server
   Response
   Request

Clone this wiki locally