0 follower

Class Yiisoft\Csrf\Synchronizer\Storage\SessionCsrfTokenStorage

InheritanceYiisoft\Csrf\Synchronizer\Storage\SessionCsrfTokenStorage
ImplementsYiisoft\Csrf\Synchronizer\Storage\CsrfTokenStorageInterface

Persists a token between requests in a user session.

Constants

Hide inherited constants

Constant Value Description Defined By
KEY '_csrf' Yiisoft\Csrf\Synchronizer\Storage\SessionCsrfTokenStorage

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( \Yiisoft\Session\SessionInterface $session, string $key self::KEY )
$session \Yiisoft\Session\SessionInterface
$key string

Session key used to store data. Default is "_csrf".

                public function __construct(SessionInterface $session, string $key = self::KEY)
{
    $this->key = $key;
    $this->session = $session;
}

            
get() public method

public string|null get ( )

                public function get(): ?string
{
    $value = $this->session->get($this->key);
    return is_string($value) ? $value : null;
}

            
remove() public method

public void remove ( )

                public function remove(): void
{
    $this->session->remove($this->key);
}

            
set() public method

public void set ( string $token )
$token string

                public function set(string $token): void
{
    $this->session->set($this->key, $token);
}