Copied!

PHPFUI requires one session variable to validate requests for a CSRF attach. The Session class wraps the details for the library.

PHPFUI also provides basic flash support for subsequent requests in the same session.

Usage

\PHPFUI\Session::setFlash('error', 'That was nasty!');

Next request:

\PHPFUI\Session::cycleFlash();
$flash = \PHPFUI\Session::getflash('error');
if ($flash)
  {
  $callout = new \PHPFUI\Callout('alert');
  $callout->add($flash);
  }
CloneableInstantiable
Constants
public PHPFUI\Session::DEBUG_HTML = 1
public PHPFUI\Session::DEBUG_JAVASCRIPT = 2
Methods
public static checkCSRF(string $request = '') : bool
public static csrf(string $quote = '') : string
public static csrfField() : string
public static cycleFlash() : void
 

Loads the flash from the previous page and removes it for the next

public static getFlash(string $key = '') : ?mixed
 

Return the flash for the key provided

public static setFlash(string $key, ?mixed $value = NULL) : void
 

Set a flash for the next request. You can sent multiple flashes by specifying different keys

  • param mixed $value can by any type that can be converted to json and stored in a session. Leave empty to delete.
public static setHandler(PHPFUI\SessionHandler $handler) : void
 

Set the session handler if you are not using the default

Properties
private static array $flash = []
 
  • var array<string,string[]>
private static ?PHPFUI\SessionHandler $handler = NULL
Methods
private static getHandler() : PHPFUI\SessionHandler
 

Get the current handler

Properties
private static array $flash = []
 
  • var array<string,string[]>
private static ?PHPFUI\SessionHandler $handler = NULL
Methods
public static checkCSRF(string $request = '') : bool
public static csrf(string $quote = '') : string
public static csrfField() : string
public static cycleFlash() : void
 

Loads the flash from the previous page and removes it for the next

public static getFlash(string $key = '') : ?mixed
 

Return the flash for the key provided

private static getHandler() : PHPFUI\SessionHandler
 

Get the current handler

public static setFlash(string $key, ?mixed $value = NULL) : void
 

Set a flash for the next request. You can sent multiple flashes by specifying different keys

  • param mixed $value can by any type that can be converted to json and stored in a session. Leave empty to delete.
public static setHandler(PHPFUI\SessionHandler $handler) : void
 

Set the session handler if you are not using the default

© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration