Warning: Reason support is experimental. We are looking for beta-tester and contributors.

How to register session data?

It is very easy to register sesion data using Eliom references. Just create an Eliom reference of scope session and its value will be different for each session (one session = one browser process).

But most of the time, what we want is to store data for one user, not for one browser instance. To do that, we group all the sessions for one user together, by creating a group of sessions. The name of the group may be for example the user id:

To create a session group, open the session by doing something like:

let open_session login password =
  lwt b = check_password login password in
  if b
  then Eliom_state.set_volatile_data_session_group
      (Int64.to_string (get_userid login))
  else ...

If you want to store user data, just create a global Eliom reference of scope group:

let myref =

And during a request, set this reference:

  Eliom_reference.Volatile.Ext.set myref (Some "user data")

The value of this reference is different for each user:

Eliom_reference.Volatile.Ext.get myref

It is possible to create persistent Eliom references (see module Eliom_reference).

Other scopes

If you want to store server side data for one browser (one session), use scope Eliom_common.default_session_scope.

If you want to store server side data for one tab of your browser (one client process), use scope Eliom_common.default_process_scope.

If you want to store server side data during one request, use scope Eliom_common.request_scope.