The qDecoder Project

qSession.c File Reference

HTTP Session Handling API. More...


Defines

#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 INTER_PREFIX   "_Q_"
#define INTER_SESSIONID   INTER_PREFIX "SESSIONID"
#define INTER_SESSION_REPO   INTER_PREFIX "REPOSITORY"
#define INTER_CREATED_SEC   INTER_PREFIX "CREATED"
#define INTER_INTERVAL_SEC   INTER_PREFIX "INTERVAL"
#define INTER_CONNECTIONS   INTER_PREFIX "CONNECTIONS"
#define SESSION_DEFAULT_TIMEOUT_INTERVAL   (30 * 60)

Functions

Q_ENTRYqSessionInit (Q_ENTRY *request, const char *dirpath)
 Initialize session.
bool qSessionSetTimeout (Q_ENTRY *session, time_t seconds)
 Set the auto-expiration seconds about user session.
const char * qSessionGetId (Q_ENTRY *session)
 Get user session id.
time_t qSessionGetCreated (Q_ENTRY *session)
 Get user session created time.
bool qSessionSave (Q_ENTRY *session)
 Update session data.
bool qSessionDestroy (Q_ENTRY *session)
 Destroy user session.


Detailed Description

HTTP Session Handling API.


Function Documentation

Q_ENTRY* qSessionInit ( Q_ENTRY request,
const char *  dirpath 
)

Initialize session.

Parameters:
request a pointer of request structure returned by qCgiRequestParse()
dirpath directory path where session data will be kept
Returns:
a pointer of malloced session data list (Q_ENTRY type)
Note:
The returned Q_ENTRY list must be de-allocated by calling qEntryFree(). And if you want to append or remove some user session data, use qEntry*() functions then finally call qSessionSave() to store updated session data.

bool qSessionSetTimeout ( Q_ENTRY session,
time_t  seconds 
)

Set the auto-expiration seconds about user session.

Parameters:
session a pointer of session structure
seconds expiration seconds
Returns:
true if successful, otherwise returns false
Note:
Default timeout is defined as SESSION_DEFAULT_TIMEOUT_INTERVAL. 1800 seconds

const char* qSessionGetId ( Q_ENTRY session  ) 

Get user session id.

Parameters:
session a pointer of session structure
Returns:
a pointer of session identifier
Note:
Do not free manually

time_t qSessionGetCreated ( Q_ENTRY session  ) 

Get user session created time.

Parameters:
session a pointer of session structure
Returns:
user session created time in UTC time seconds

bool qSessionSave ( Q_ENTRY session  ) 

Update session data.

Parameters:
session a pointer of session structure
Returns:
true if successful, otherwise returns false

bool qSessionDestroy ( Q_ENTRY session  ) 

Destroy user session.

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


[Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference]