|
cutelyst
3.7.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
|
#include <session.h>

Public Member Functions | |
| Session (Application *parent) | |
| void | setStorage (SessionStore *store) |
| virtual bool | setup (Application *app) final |
| SessionStore * | storage () const |
Public Member Functions inherited from Cutelyst::Plugin | |
| Plugin (Application *parent) | |
Static Public Member Functions | |
| static void | changeExpires (Context *c, quint64 expires) |
| static QString | deleteReason (Context *c) |
| static void | deleteSession (Context *c, const QString &reason=QString()) |
| static void | deleteValue (Context *c, const QString &key) |
| static void | deleteValues (Context *c, const QStringList &keys) |
| static quint64 | expires (Context *c) |
| static QString | id (Context *c) |
| static bool | isValid (Context *c) |
| static void | setValue (Context *c, const QString &key, const QVariant &value) |
| static QVariant | value (Context *c, const QString &key, const QVariant &defaultValue=QVariant()) |
Plugin providing methods for session management.
There are some options you can set in your application configuration file in the Cutelyst_Session_Plugin section.
Integer value, default: 7200
Expiration duration of the session in seconds.
Boolean value, default: false
If enabled, the plugin will check if the IP address of the requesting user matches the address stored in the session data. In case of a mismatch, the session will be deleted.
Boolean value, default: false
If true, the plugin will check if the user agent of the requesting user matches the user agent stored in the session data. In case of a mismatch, the session will be deleted.
Boolean value, default: true
If true, the session cookie will have the httpOnly flag set so that the cookie is not accessible to JavaScript's Document.cookie API.
Boolean value, default: false
If true, the session cookie will have the secure flag set so that the cookie is only sent to the server with an encrypted request over the HTTPS protocol.
| Session::Session | ( | Cutelyst::Application * | parent | ) |
Constructs a new session object with the given parent.
Definition at line 35 of file session.cpp.
|
static |
change the session expiration time for this session
Note that this only works to set the session longer than the config setting.
Definition at line 123 of file session.cpp.
|
static |
This method contains a string with the reason a session was deleted. Possible values include:
Definition at line 145 of file session.cpp.
References Cutelyst::Context::stash().
|
static |
This method is used to invalidate a session. It takes an optional parameter which will be saved in deleteReason if provided.
NOTE: This method will also delete your flash data.
Definition at line 136 of file session.cpp.
|
static |
Removes the session key.
Definition at line 188 of file session.cpp.
References Cutelyst::Context::setStash(), and Cutelyst::Context::stash().
|
static |
Removes all session keys.
Definition at line 211 of file session.cpp.
References Cutelyst::Context::setStash(), and Cutelyst::Context::stash().
Referenced by Cutelyst::StatusMessage::load(), and Cutelyst::AuthenticationRealm::removePersistedUser().
|
static |
This method returns the time when the current session will expire, or 0 if there is no current session. If there is a session and it already expired, it will delete the session and return 0 as well.
Definition at line 103 of file session.cpp.
References Cutelyst::Context::stash().
Referenced by changeExpires().
|
static |
Returns the current session id or null if there is no current session
Definition at line 85 of file session.cpp.
References Cutelyst::Context::stash().
Referenced by changeExpires().
|
static |
Returns true if the session is valid.
Definition at line 236 of file session.cpp.
| void Session::setStorage | ( | SessionStore * | store | ) |
Sets the session storage
Definition at line 71 of file session.cpp.
|
finalvirtual |
Sets up the plugin and loads the configuration.
Reimplemented from Cutelyst::Plugin.
Definition at line 46 of file session.cpp.
References Cutelyst::Application::afterDispatch(), Cutelyst::Engine::config(), Cutelyst::Application::engine(), and Cutelyst::Application::postForked().
|
static |
Sets the value for session key to value. If the key already exists, the previous value is overwritten.
Definition at line 165 of file session.cpp.
References Cutelyst::Context::setStash(), Cutelyst::Context::stash(), and value().
Referenced by Cutelyst::StatusMessage::error(), Cutelyst::StatusMessage::errorQuery(), Cutelyst::AuthenticationRealm::persistUser(), Cutelyst::StatusMessage::status(), and Cutelyst::StatusMessage::statusQuery().
| SessionStore * Session::storage | ( | ) | const |
Returns the session storage
Definition at line 79 of file session.cpp.
|
static |
Returns the value for session key. If the session key doesn't exist, returns defaultValue.
Definition at line 150 of file session.cpp.
References Cutelyst::Context::stash().
Referenced by Cutelyst::StatusMessage::load(), setValue(), and Cutelyst::AuthenticationRealm::userIsRestorable().