Public Member Functions

HttpSessionStore Class Reference

Stores HTTP sessions and deletes them when they have expired. More...

#include <httpsessionstore.h>

List of all members.

Public Member Functions

 HttpSessionStore (QSettings *settings, QObject *parent)
 Constructor.
virtual ~HttpSessionStore ()
 Destructor.
QByteArray getSessionId (HttpRequest &request, HttpResponse &response)
 Get the ID of the current HTTP session, if it is valid.
HttpSession getSession (HttpRequest &request, HttpResponse &response, bool allowCreate=true)
 Get the session of a HTTP request, eventually create a new one.
HttpSession getSession (const QByteArray id)
 Get a HTTP session by it's ID number.
void removeSession (HttpSession session)
 Delete a session.

Detailed Description

Stores HTTP sessions and deletes them when they have expired.

The following configuration settings are required in the config file:

  expirationTime=3600000
  cookieName=sessionid
  

The following additional configurations settings are optionally:

  cookiePath=/
  cookieComment=Session ID
  cookieDomain=stefanfrings.de
  

Definition at line 32 of file httpsessionstore.h.


Constructor & Destructor Documentation

HttpSessionStore::HttpSessionStore ( QSettings *  settings,
QObject *  parent 
)

Constructor.

Definition at line 10 of file httpsessionstore.cpp.


Member Function Documentation

HttpSession HttpSessionStore::getSession ( HttpRequest request,
HttpResponse response,
bool  allowCreate = true 
)

Get the session of a HTTP request, eventually create a new one.

This method is thread safe. New sessions can only be created before the first byte has been written to the HTTP response.

Parameters:
request Used to get the session cookie
response Used to get and set the new session cookie
allowCreate can be set to false, to disable the automatic creation of a new session.
Returns:
If autoCreate is disabled, the function returns a null session if there is no session.
See also:
HttpSession::isNull()

Definition at line 46 of file httpsessionstore.cpp.

HttpSession HttpSessionStore::getSession ( const QByteArray  id  ) 

Get a HTTP session by it's ID number.

This method is thread safe.

Returns:
If there is no such session, the function returns a null session.
Parameters:
id ID number of the session
See also:
HttpSession::isNull()

Definition at line 75 of file httpsessionstore.cpp.

QByteArray HttpSessionStore::getSessionId ( HttpRequest request,
HttpResponse response 
)

Get the ID of the current HTTP session, if it is valid.

This method is thread safe.

Warning:
Sessions may expire at any time, so subsequent calls of getSession() might return a new session with a different ID.
Parameters:
request Used to get the session cookie
response Used to get and set the new session cookie
Returns:
Empty string, if there is no valid session.

Definition at line 26 of file httpsessionstore.cpp.


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