
- Simple and intuitive API: Easy to use methods for session manipulation.
- Flash messages support: Conveniently handle one-time messages for user feedback.
- Secure session handling: Enhanced security features to prevent common vulnerabilities.
- Flexible configuration: Customize session behavior to fit your application's needs.
- PSR-4 autoloading: Fully compliant with modern PHP standards.
Use Composer to install Fastpress\Session into your project:
composer require fastpress/session- PHP 7.4 or higher.
Starts the session.
Returns:
trueif the session was started successfully,falseotherwise.
Regenerates the session ID.
Parameters:
$deleteOldSession: Whether to delete the old session data.
Returns:
trueon success, throwsRuntimeExceptionon failure.
Generates a CSRF token.
Returns:
- The generated CSRF token.
Validates a CSRF token.
Parameters:
$token: The token to validate.
Returns:
trueif the token is valid,falseotherwise.
Sets a flash message.
Parameters:
$key: The key for the flash message.$value: The value of the flash message.$type: The type of flash message (e.g., 'info', 'success', 'error').
Returns:
void
Gets a flash message.
Parameters:
$key: The key for the flash message.$default: The default value to return if the flash message does not exist.
Returns:
- The flash message value or the default value.
Closes the session for writing.
Returns:
trueon success,falseotherwise.
Performs garbage collection on the session.
Parameters:
$force: Whether to force garbage collection.
Returns:
trueon success,falseotherwise.
Destroys the session.
Returns:
void
Sets a session variable.
Parameters:
$key: The key for the session variable.$value: The value of the session variable.
Returns:
void
Gets a session variable.
Parameters:
$key: The key for the session variable.$default: The default value to return if the session variable does not exist.
Returns:
- The session variable value or the default value.
Checks if a session variable exists.
Parameters:
$key: The key for the session variable.
Returns:
trueif the session variable exists,falseotherwise.
Deletes a session variable.
Parameters:
$key: The key for the session variable.
Returns:
void
Clears all session variables.
Returns:
void