Aerys\Request::setLocalVar PHP Method

setLocalVar() public method

Each request has its own mutable local storage to which application callables and middleware may read and write data. Other callables which are aware of this data can then access it without the server being tightly coupled to specific implementations.
public setLocalVar ( string $key, mixed $value ) : void
$key string
$value mixed
return void
    public function setLocalVar(string $key, $value);

Usage Example

Ejemplo n.º 1
0
 public function __construct(Request $request)
 {
     $this->request = $request;
     $config = $request->getLocalVar("aerys.session.config");
     assert(\is_array($config), 'No middleware was loaded or Aerys\\Session class instantiated in invalid context');
     $this->driver = $config["driver"];
     $config += static::CONFIG;
     $request->setLocalVar("aerys.session.config", $config);
     $id = $request->getCookie($config["name"]);
     if (\strlen($id) === self::ID_LENGTH && strspn($id, self::ALLOWED_ID_CHARS) === self::ID_LENGTH) {
         $this->setId($id);
     }
     $this->ttl = $config["ttl"];
     $this->maxlife = $config["maxlife"];
 }
All Usage Examples Of Aerys\Request::setLocalVar