Flick
Guide Validation Services API Pro Examples GitHub
Docs / Reference

Session

Reading and writing Flick's session data.

Session Helpers

addSessionValue

Sets a value in the Flick session.

$form->addSessionValue('user_id', 123);

getSessionValue

Retrieves a value from the Flick session.

$userId = $form->getSessionValue('user_id');

hasSessionValue

Checks if a value exists in the Flick session.

if ($form->hasSessionValue('user_id')) {
    // Value exists
}

deleteSessionValue

Removes a value from the Flick session.

$form->deleteSessionValue('user_id');

sessionIsActive

Checks if the PHP session is active.

if ($form->sessionIsActive()) {
    // Session is active
}

Static Session Methods

These methods manage the default session adapter at the application level.

Flick::setDefaultSession

Sets the default session adapter for all Flick instances.

use Flick\Flick;

// In a service provider
Flick::setDefaultSession(new LaravelSession(session()));

// All subsequent Flick instances use this adapter
$form = Flick::make('bootstrap');

Flick::getDefaultSession

Returns the currently configured default session adapter, or null if not set.

$session = Flick::getDefaultSession();

Flick::resetDefaultSession

Resets the default session adapter to null (useful in tests).

beforeEach(function () {
    Flick::resetDefaultSession();
});