Cutelyst  1.11.0
Public Member Functions | Static Public Member Functions | List of all members
Cutelyst::Session Class Reference
Inheritance diagram for Cutelyst::Session:
Inheritance graph
[legend]

Public Member Functions

 Session (Application *parent)
 
void setStorage (SessionStore *store)
 
virtual bool setup (Application *app) final
 
SessionStorestorage () 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())
 

Detailed Description

Definition at line 59 of file session.h.

Constructor & Destructor Documentation

Session::Session ( Cutelyst::Application parent)

Constructs a new session object with the given parent.

Definition at line 48 of file session.cpp.

Member Function Documentation

void Session::changeExpires ( Context c,
quint64  expires 
)
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 134 of file session.cpp.

References id().

QString Session::deleteReason ( Context c)
static

This method contains a string with the reason a session was deleted. Possible values include:

  • session expired
  • address mismatch
  • user agent mismatch

Definition at line 156 of file session.cpp.

void Session::deleteSession ( Context c,
const QString &  reason = QString() 
)
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 147 of file session.cpp.

Referenced by isValid().

void Session::deleteValue ( Context c,
const QString &  key 
)
static

Removes the session key.

Definition at line 199 of file session.cpp.

void Session::deleteValues ( Context c,
const QStringList &  keys 
)
static

Removes all session keys.

Definition at line 222 of file session.cpp.

Referenced by Cutelyst::StatusMessage::load(), and Cutelyst::AuthenticationRealm::removePersistedUser().

quint64 Session::expires ( Context c)
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 114 of file session.cpp.

Referenced by isValid().

QString Session::id ( Cutelyst::Context c)
static

Returns the current session id or null if there is no current session

Definition at line 96 of file session.cpp.

Referenced by changeExpires(), and isValid().

bool Session::isValid ( Cutelyst::Context c)
static
void Session::setStorage ( SessionStore store)

Sets the session storage

Definition at line 80 of file session.cpp.

bool Session::setup ( Application app)
finalvirtual

If config has [Plugin_Session] expires = 1234 it will change de default expires which is 7200 (two hours)

Reimplemented from Cutelyst::Plugin.

Definition at line 59 of file session.cpp.

References Cutelyst::Application::afterDispatch(), Cutelyst::Engine::config(), Cutelyst::Application::engine(), and Cutelyst::Application::postForked().

void Session::setValue ( Cutelyst::Context c,
const QString &  key,
const QVariant &  value 
)
static

Sets the value for session key to value. If the key already exists, the previous value is overwritten.

Definition at line 176 of file session.cpp.

Referenced by Cutelyst::StatusMessage::error(), Cutelyst::StatusMessage::errorQuery(), Cutelyst::AuthenticationRealm::persistUser(), Cutelyst::Authentication::setup(), Cutelyst::StatusMessage::status(), and Cutelyst::StatusMessage::statusQuery().

SessionStore * Session::storage ( ) const

Returns the session storage

Definition at line 90 of file session.cpp.

QVariant Session::value ( Cutelyst::Context c,
const QString &  key,
const QVariant &  defaultValue = QVariant() 
)
static

Returns the value for session key. If the session key doesn't exist, returns defaultValue.

Definition at line 161 of file session.cpp.

Referenced by Cutelyst::StatusMessage::load(), Cutelyst::Authentication::setup(), and Cutelyst::AuthenticationRealm::userIsRestorable().