bonsaicode / session
Session handling for PHP, with built-in controls for handling unstable (mobile) network connections.
1.1.0
2026-11-14 17:18 UTC
Requires
- php: >=7.3
- ext-session: *
Requires (Dev)
- phpunit/phpunit: ^9.6 || ^10.5 || ^11.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Session handler provides the following features:
- Start a session with a given timeout.
- Regenerate the session id (e.g. after authentication).
- Remove the session.
This attempts to preserve the session on an unstable network connection (which may occur on mobile phones) when starting the session and when regenerating the session id.
Requirements
- PHP 7.3 or higher
Installation
To install the package, run the following command in the console:
$ composer require "bonsaicode/session"
Configure
To adjust the default session timeout, edit Session::$TIMEOUT.
Usage
<?php
# at the top of the login page and in your logout page:
BonsaiCode\Session::remove();
# at the top of all pages with session:
BonsaiCode\Session::start();
# after logging in, prevent session fixation by running this:
BonsaiCode\Session::regenerateId();
?>