All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions | Data Fields
onion_sessions_t Struct Reference

Storage for all sessions knownThis is a simple storage for sessions. More...

#include <types.h>

Public Member Functions

char * onion_sessions_generate_id ()
 Generates a unique id.
onion_sessionsonion_sessions_new ()
 Creates a sessions data object, which keeps all sessions in memory.
void onion_sessions_free (onion_sessions *sessions)
 Frees the memory used by sessions.
char * onion_sessions_create (onion_sessions *sessions)
 Creates a new session and returns the sessionId.
onion_dictonion_sessions_get (onion_sessions *sessions, const char *sessionId)
 Returns a session dictionary.
void onion_sessions_remove (onion_sessions *sessions, const char *sessionId)
 Removes a session from the storage.

Data Fields

void * data
onion_dict *(* get )(onion_sessions *sessions, const char *sessionid)
void(* save )(onion_sessions *sessions, const char *sessionid, onion_dict *data)
void(* free )(onion_sessions *sessions)

Detailed Description

Storage for all sessions known

This is a simple storage for sessions.

Sessions are thread safe to use.

The sessions themselves are not created until some data is written to it by the program. This way we avoid "session attack" where a malicious user sends many petitions asking for new sessions.

FIXME to add some LRU so that on some moment we can remove old sessions.

Member Function Documentation

void onion_sessions_remove ( onion_sessions sessions,
const char *  sessionId 

Removes a session from the storage.

References save.

Referenced by onion_request_t::onion_request_session_free().

Field Documentation

void* onion_sessions_t::data
void(* onion_sessions_t::free)(onion_sessions *sessions)
onion_dict*(* onion_sessions_t::get)(onion_sessions *sessions, const char *sessionid)
void(* onion_sessions_t::save)(onion_sessions *sessions, const char *sessionid, onion_dict *data)

The documentation for this struct was generated from the following files: