libonion
|
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_sessions * | onion_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_dict * | onion_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) |
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.
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().
void* onion_sessions_t::data |
void(* onion_sessions_t::free)(onion_sessions *sessions) |
Referenced by onion_sessions_free(), onion_sessions_mem_new(), onion_sessions_redis_new(), and onion_sessions_sqlite3_new().
onion_dict*(* onion_sessions_t::get)(onion_sessions *sessions, const char *sessionid) |
Referenced by onion_sessions_get(), onion_sessions_mem_new(), onion_sessions_redis_new(), and onion_sessions_sqlite3_new().
void(* onion_sessions_t::save)(onion_sessions *sessions, const char *sessionid, onion_dict *data) |