final class CsrfTokenManager (View source)

Maintains independently named tokens inside the default session's CSRF namespace.

Constants

private NAMESPACE_NAME

Methods

Connects token persistence to the supplied physical session without owning its lifecycle.

string
token(string $name = 'default')

Returns the stable token for a name, creating it when absent or corrupt.

string
bool
validate(string $token, string $name = 'default')

Compares a submitted value with the token stored for the requested name.

bool
string
regenerate(string $name = 'default')

Replaces and returns only the token associated with the requested name.

string
void
forget(string $name = 'default')

Removes one named token while preserving every other CSRF token.

void

Details

__construct

__construct(SessionInterface $session)

Connects token persistence to the supplied physical session without owning its lifecycle.

Parameters

SessionInterface $session

token

string token(string $name = 'default')

Returns the stable token for a name, creating it when absent or corrupt.

Parameters

string $name

Return Value

string

validate

bool validate(string $token, string $name = 'default')

Compares a submitted value with the token stored for the requested name.

Parameters

string $token
string $name

Return Value

bool

regenerate

string regenerate(string $name = 'default')

Replaces and returns only the token associated with the requested name.

Parameters

string $name

Return Value

string

forget

void forget(string $name = 'default')

Removes one named token while preserving every other CSRF token.

Parameters

string $name

Return Value

void