Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
Loading...
Searching...
No Matches
orbit::middleware::Session Class Reference

The current request's session (req.session). More...

#include <SessionManager.hpp>

Public Member Functions

const std::string & id () const
 
bool is_new () const
 True if this request created the session.
 
std::optional< std::string > get (const std::string &key) const
 
void set (const std::string &key, std::string value)
 
void erase (const std::string &key)
 
const SessionData & data () const
 
void regenerate ()
 Issues a new ID and keeps the data; the old ID stops working.
 
void destroy ()
 Deletes the session and expires the cookie.
 

Private Attributes

std::string id_
 
std::string previous_id_
 
SessionData data_
 
bool is_new_ = false
 
bool dirty_ = false
 
bool destroyed_ = false
 

Friends

class SessionManager
 

Detailed Description

The current request's session (req.session).

Changes are saved when the response is sent. Call regenerate() after a login or privilege change, so an ID known before login (session fixation) becomes useless, and destroy() on logout.

Member Function Documentation

◆ data()

const SessionData & orbit::middleware::Session::data ( ) const
inline

◆ destroy()

void orbit::middleware::Session::destroy ( )

Deletes the session and expires the cookie.

◆ erase()

void orbit::middleware::Session::erase ( const std::string &  key)

◆ get()

std::optional< std::string > orbit::middleware::Session::get ( const std::string &  key) const

◆ id()

const std::string & orbit::middleware::Session::id ( ) const
inline

◆ is_new()

bool orbit::middleware::Session::is_new ( ) const
inline

True if this request created the session.

◆ regenerate()

void orbit::middleware::Session::regenerate ( )

Issues a new ID and keeps the data; the old ID stops working.

◆ set()

void orbit::middleware::Session::set ( const std::string &  key,
std::string  value 
)

Friends And Related Symbol Documentation

◆ SessionManager

friend class SessionManager
friend

Member Data Documentation

◆ data_

SessionData orbit::middleware::Session::data_
private

◆ destroyed_

bool orbit::middleware::Session::destroyed_ = false
private

◆ dirty_

bool orbit::middleware::Session::dirty_ = false
private

◆ id_

std::string orbit::middleware::Session::id_
private

◆ is_new_

bool orbit::middleware::Session::is_new_ = false
private

◆ previous_id_

std::string orbit::middleware::Session::previous_id_
private

The documentation for this class was generated from the following file: