This class stores data for a single HTTP session. More...
#include <httpsession.h>
Classes | |
struct | HttpSessionData |
Public Member Functions | |
HttpSession (bool canStore=false) | |
Constructor. | |
HttpSession (const HttpSession &other) | |
Copy constructor. | |
HttpSession & | operator= (const HttpSession &other) |
Copy operator. | |
virtual | ~HttpSession () |
Destructor. | |
QByteArray | getId () const |
Get the unique ID of this session. | |
bool | isNull () const |
Null sessions cannot store data. | |
void | set (const QByteArray &key, const QVariant &value) |
Set a value. | |
void | remove (const QByteArray &key) |
Remove a value. | |
QVariant | get (const QByteArray &key) const |
Get a value. | |
bool | contains (const QByteArray &key) const |
Check if a key exists. | |
QMap< QByteArray, QVariant > | getAll () const |
Get a copy of all data stored in this session. | |
qint64 | getLastAccess () const |
Get the timestamp of last access. | |
void | setLastAccess () |
Set the timestamp of last access, to renew the timeout period. |
This class stores data for a single HTTP session.
A session can store any number of key/value pairs. This class uses implicit sharing for read and write access. This class is thread safe.
Definition at line 21 of file httpsession.h.
HttpSession::HttpSession | ( | bool | canStore = false |
) |
Constructor.
canStore | The session can store data, if this parameter is true. Otherwise all calls to set() and remove() do not have any effect. |
Definition at line 11 of file httpsession.cpp.
HttpSession::HttpSession | ( | const HttpSession & | other | ) |
Copy constructor.
Creates another HttpSession object that shares the data of the other object.
Definition at line 26 of file httpsession.cpp.
HttpSession::~HttpSession | ( | ) | [virtual] |
bool HttpSession::contains | ( | const QByteArray & | key | ) | const |
QVariant HttpSession::get | ( | const QByteArray & | key | ) | const |
QMap< QByteArray, QVariant > HttpSession::getAll | ( | ) | const |
Get a copy of all data stored in this session.
Changes to the session do not affect the copy and vice versa. This method is thread safe.
Definition at line 131 of file httpsession.cpp.
QByteArray HttpSession::getId | ( | ) | const |
Get the unique ID of this session.
This method is thread safe.
Definition at line 82 of file httpsession.cpp.
qint64 HttpSession::getLastAccess | ( | ) | const |
Get the timestamp of last access.
That is the time when the last HttpSessionStore::getSession() has been called. This method is thread safe.
Definition at line 141 of file httpsession.cpp.
bool HttpSession::isNull | ( | ) | const |
Null sessions cannot store data.
All calls to set() and remove() do not have any effect.This method is thread safe.
Definition at line 91 of file httpsession.cpp.
HttpSession & HttpSession::operator= | ( | const HttpSession & | other | ) |
Copy operator.
Detaches from the current shared data and attaches to the data of the other object.
Definition at line 38 of file httpsession.cpp.
void HttpSession::remove | ( | const QByteArray & | key | ) |
void HttpSession::set | ( | const QByteArray & | key, | |
const QVariant & | value | |||
) |
void HttpSession::setLastAccess | ( | ) |
Set the timestamp of last access, to renew the timeout period.
Called by HttpSessionStore::getSession(). This method is thread safe.
Definition at line 152 of file httpsession.cpp.