QtWebApp
|
This class stores data for a single HTTP session. More...
#include <httpsession.h>
Public Member Functions | |
HttpSession (const bool canStore=false) | |
Constructor. More... | |
HttpSession (const HttpSession &other) | |
Copy constructor. More... | |
HttpSession & | operator= (const HttpSession &other) |
Copy operator. More... | |
virtual | ~HttpSession () |
Destructor. More... | |
QByteArray | getId () const |
Get the unique ID of this session. More... | |
bool | isNull () const |
Null sessions cannot store data. More... | |
void | set (const QByteArray &key, const QVariant &value) |
Set a value. More... | |
void | remove (const QByteArray &key) |
Remove a value. More... | |
QVariant | get (const QByteArray &key) const |
Get a value. More... | |
bool | contains (const QByteArray &key) const |
Check if a key exists. More... | |
QMap< QByteArray, QVariant > | getAll () const |
Get a copy of all data stored in this session. More... | |
qint64 | getLastAccess () const |
Get the timestamp of last access. More... | |
void | setLastAccess () |
Set the timestamp of last access, to renew the timeout period. More... | |
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 23 of file httpsession.h.
HttpSession::HttpSession | ( | const 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 12 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 30 of file httpsession.cpp.
|
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 155 of file httpsession.cpp.
QByteArray HttpSession::getId | ( | ) | const |
Get the unique ID of this session.
This method is thread safe.
Definition at line 95 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 167 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 107 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 44 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 180 of file httpsession.cpp.