Maintains sessions in ProcessWire, authentication, persistent variables, notices and redirects.

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Session class also inherits all the methods and properties of: Wire.

Common / Authentication / Notices / For hooks

Show “$session”             Show Arguments        


SessionCSRFReturn an instance of ProcessWire’s CSRF object, which provides an API for cross site request forgery protection.
Can also be used as property: $session->CSRF
mixedGet a session variable
arrayGet all session variables in an associative array
$session->getFor($ns, string $key)
mixedGet a session variable within a given namespace
arrayGet the session history (if enabled)
string or intGet the IP address of the current user
ArrayObjectAllow iteration of session variables
boolAre session cookie(s) present?
$session->redirect(string $url)
(nothing)Redirect this session to another URL.
$thisUnset a session variable
$thisRemove all session variables in given namespace
$session->removeFor($ns, string $key)
$thisUnset a session variable within a namespace
$session->set($key, $value)
$thisSet a session variable
$session->setFor($ns, string $key, mixed $value)
$thisSet a session variable within a given namespace


User or nullLogin a user without requiring a password
$session->login($name, string $pass)
User or nullLogin a user with the given name and password
$thisLogout the current user, and clear all session variables


$session->error(string $text)
$thisQueue an error to appear on the next pageview
$session->message(string $text)
$thisQueue a message to appear on the next pageview
(nothing)Remove queued notices
$session->warning(string $text)
$thisQueue a warning to appear the next pageview

For hooks

These methods are only useful for hooking and should not be called directly.

Additional methods and properties

In addition to the methods and properties above, Session also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.115