$session->getVal() method

Get a session variable or return $val argument if session value not present

This is the same as get() except that it lets you specify a fallback return value in the method call. For a namespace version use Session::getValFor() instead.

Available since version 3.0.133.

Usage

// basic usage
$mixed = $session->getVal(string $key);

// usage with all arguments
$mixed = $session->getVal(string $key, mixed $val = null);

Arguments

NameType(s)Description
keystring

Name of session variable to retrieve.

val (optional)mixed

Fallback value to return if session does not have it.

Return value

mixed

Returns value of seession variable, or NULL if not found.


$session methods and properties

API reference based on ProcessWire core version 3.0.236

Latest news

  • ProcessWire Weekly #518
    The 518th issue of ProcessWire Weekly brings in all the latest news from the ProcessWire community. Modules, sites, and more. Read on!
    Weekly.pw / 13 April 2024
  • ProFields Table Field with Actions support
    This week we have some updates for the ProFields table field (FieldtypeTable). These updates are primarily focused on adding new tools for the editor to facilitate input and management of content in a table field.
    Blog / 12 April 2024
  • Subscribe to weekly ProcessWire news

“…building with ProcessWire was a breeze, I really love all the flexibility the system provides. I can’t imagine using any other CMS in the future.” —Thomas Aull