$session API variable / Session class

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.

Show $var?             Show args?        

Common

NameReturnSummary 
$session->CSRF()
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
 
$session->get($key)
mixedGet a session variable 
$session->getAll()
arrayGet all session variables in an associative array 
$session->getFor($ns, string $key)
mixedGet a session variable within a given namespace 
$session->getHistory()
arrayGet the session history (if enabled) 
$session->getIP()
string intGet the IP address of the current user 
$session->getIterator()
ArrayObjectAllow iteration of session variables 
$session->hasCookie()
boolAre session cookie(s) present? 
$session->redirect(string $url)
(nothing)Redirect this session to another URL.
$session->remove($key)
$thisUnset a session variable 
$session->removeAllFor($ns)
$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 

Authentication

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.127

Twitter updates

  • New post: This week ProcessWire ProMailer has been released, plus we’ve got a nice upgrade in our community support forum, and more— More
    15 March 2019
  • New post: This week we look at the latest version of ProcessWire, 3.0.127 with nearly 30 new commits resolving dozens of older issue reports and a couple useful new features— More
    1 March 2019
  • New post: This week we take a look at what’s in ProcessWire 3.0.126 which focuses largely on resolving issue reports, but also includes a handy new Page if() method— More
    15 February 2019

Latest news

  • ProcessWire Weekly #253
    In the 253rd issue of ProcessWire Weekly we'll introduce the ProMailer Pro module, cover the upgrade made to our support forum software, check out Sanitizer Transliterate, and pick a new site of the week. Read on!
    Weekly.pw / 16 March 2019
  • ProcessWire ProMailer now available
    This week ProcessWire ProMailer has been released, plus we’ve got a nice upgrade in our community support forum, and more.
    Blog / 15 March 2019
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH