XQuery/Basic Session Management

Motivation
You want to associate some behavior of your web application with a users's login session.

Method
There are several functions provided by eXist and other web servers to manage information associated with a login session.

Before you add any session attributes this might return only a single variable such as:

This will return the following attributes:

These attributes will remain associated with the user until the user logs out or their session times out, typically after 15 minutes of inactivity.

One sample use of session attributes is to keep track of user interface preferences. For example if a user wants to have their data sorted by a person's zip code you can add that to their session variable.

let $set-sort := session:set-attribute('sort', 'zip-code')