Fosi Fossil Service
Small teams. Open source. Built on Fossil.

CaaS / Lamina

Unified Management for Fossil Repositories

Public | Owner: CaaS | Default branch: trunk | Last update: 2026-10-25 00:41

Artifact 090b3a111f2a00022cc3a4b28a10b2dfae1d3c1cfcf0bacd57b70c581bc2083d:


Sessions

Sessions in Nova are handled by the nova_session module. This module is responsible for setting and getting session-values, as well as managing the session data. This means that you can store data in sessions without having to worry about session ids or anything like that - it's all handled for you.

API

nova_session:set/3

-spec set(Req :: cowboy_req:req(), Key :: binary(), Value :: binary()) ->
                 ok | {error, Reason :: atom()} | no_return().

This function is used to set a session value. It takes two arguments: the request object, the name of the session-key and the value.

nova_session:set(Req, "name", "John Doe").

nova_session:get/2

-spec get(Req :: cowboy_req:req(), Key :: binary()) ->
          {ok, Value :: binary()} | {error, Reason :: atom()} | no_return().

This function is used to get a session value. It takes two arguments: the request object and the name of the session-key.

nova_session:get(Req, "name").

nova_session:delete/2

-spec delete(Req :: cowboy_req:req(), Key :: binary()) -> {ok, Req :: cowboy_req:req()} |
                                                          {error, Reason :: atom()} | no_return().

This function is used to delete a value. It takes two arguments: the request object and the name of the value.

nova_session:delete(Req, "name").

nova_session:delete/1

-spec delete(Req :: cowboy_req:req()) -> {ok, Req :: cowboy_req:req()} |
                                           {error, Reason :: atom()} | no_return().

This function is used to delete all values. It takes one argument: the request object.

nova_session:delete(Req).

Enabling Sessions

Sessions are enabled by default in Nova, but if you need to disable them, you can do so by setting the use_sessions configuration option to false. This will disable sessions for the entire site. It's also possible to set the backend for the session data. By default, the session data is stored in an ETS table in the Erlang VM but it's quite easy to implement a custom backend.

Backend

You can implement your own backend by creating a module that implements the nova_session behaviour. This behaviour has four functions that need to be implemented: get_value/2, set_value/3, delete_value/1 and delete_value/2.
Optionally you can also implement start_link/0, which will start a process under nova's supervisor for handling infrastructure of your handler, if it is necessary. For example, in default nova_session_ets module it starts a gen_server for managing underlying ETS table.

-module(my_session_backend).
-behaviour(nova_session).

-export([get_value/2, set_value/3, delete_value/1, delete_value/2]).

get_value(Req, _Key) ->
    %% Your code here,
    {ok, Req}.

set_value(Req, _Key, ) ->
    %% Your code here,
    {ok, Req}.

delete_value(Req) ->
    %% Your code here,
    {ok, Req}.

delete_value(Req, _Key) ->
    %% Your code here,
    {ok, Req}.

This module can then be set as the backend in the sys.config file under nova.

{session_manager, my_session_backend}.

Clone

You can clone this repository with the following command:

fossil clone https://fosi.dev/CaaS/Lamina

Contribute

The best way to contribute is through e-mail. See the project documentation for more details.