qDecoder API Reference

Macros | Functions
qcgisess.c File Reference

Detailed Description

CGI Session API.

Macros

#define SESSION_DEFAULT_REPOSITORY   "/tmp"
 
#define SESSION_ID   "QSESSIONID"
 
#define SESSION_PREFIX   "qsession-"
 
#define SESSION_STORAGE_EXTENSION   ".properties"
 
#define SESSION_TIMEOUT_EXTENSION   ".expire"
 
#define SESSION_TIMETOCLEAR_FILENAME   "qsession-timetoclear"
 
#define SESSION_DEFAULT_TIMEOUT_INTERVAL   (30 * 60)
 

Functions

qentry_tqcgisess_init (qentry_t *request, const char *dirpath)
 Initialize session. More...
 
bool qcgisess_settimeout (qentry_t *session, time_t seconds)
 Set the auto-expiration seconds about user session. More...
 
const char * qcgisess_getid (qentry_t *session)
 Get user session id. More...
 
time_t qcgisess_getcreated (qentry_t *session)
 Get user session created time. More...
 
bool qcgisess_save (qentry_t *session)
 Update session data. More...
 
bool qcgisess_destroy (qentry_t *session)
 Destroy user session. More...
 

Function Documentation

qentry_t* qcgisess_init ( qentry_t request,
const char *  dirpath 
)

Initialize session.

Parameters
requesta pointer of request structure returned by qcgireq_parse()
dirpathdirectory path where session data will be kept
Returns
a pointer of malloced session data list (qentry_t type)
Note
The returned qentry_t list must be de-allocated by calling qentry_t->free(). And if you want to append or remove some user session data, use qentry_t->*() functions then finally call qcgisess_save() to store updated session data.
bool qcgisess_settimeout ( qentry_t session,
time_t  seconds 
)

Set the auto-expiration seconds about user session.

Parameters
sessiona pointer of session structure
secondsexpiration seconds
Returns
true if successful, otherwise returns false
Note
Default timeout is defined as SESSION_DEFAULT_TIMEOUT_INTERVAL. 1800 seconds
const char* qcgisess_getid ( qentry_t session)

Get user session id.

Parameters
sessiona pointer of session structure
Returns
a pointer of session identifier
Note
Do not free manually
time_t qcgisess_getcreated ( qentry_t session)

Get user session created time.

Parameters
sessiona pointer of session structure
Returns
user session created time in UTC time seconds
bool qcgisess_save ( qentry_t session)

Update session data.

Parameters
sessiona pointer of session structure
Returns
true if successful, otherwise returns false
bool qcgisess_destroy ( qentry_t session)

Destroy user session.

Parameters
sessiona pointer of session structure
Returns
true if successful, otherwise returns false
Note
If you only want to de-allocate session structure, just call qentry_t->free(). This will remove all user session data permanantely and also free the session structure.