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 __construct( \Yiisoft\Session\SessionInterface $session, string $key self::KEY ): mixed
$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 get( ): string|null

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

            
remove() public method

public remove( ): void

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

            
set() public method

public set( string $token ): void
$token string

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