libcex  1.0.0
Modern C++11 embedded webserver library
Classes | Functions
session.hpp File Reference

Session middleware function. More...

#include <string>
#include "core.hpp"

Go to the source code of this file.

Classes

struct  cex::SessionOptions
 Contains all options for the sessionHandler middleware. More...
 

Functions

MiddlewareFunction cex::sessionHandler (std::shared_ptr< SessionOptions > opts=nullptr)
 Creates a middleware function which gets/creates session IDs. More...
 

Detailed Description

Session middleware function.

Example:

// using default session options
app.use(cex::sessionHandler());

Function Documentation

◆ sessionHandler()

MiddlewareFunction cex::sessionHandler ( std::shared_ptr< SessionOptions opts = nullptr)

Creates a middleware function which gets/creates session IDs.

Extracts the cookie with the configured name from the request. If no cookie could be found, a new session ID is created and a cookie is attached to the Response object. The session ID is also added to the Request object's property list. The name of the property corresponds to the cookie/session ID name.