illuminate/session
Illuminate Session provides Laravel’s session management layer, including session stores, handlers, middleware support, flash data, and CSRF-friendly session integration. Use it to persist user state across requests with a consistent API, in Laravel or standalone.
Start by installing illuminate/session via Composer, then register its service provider and facade aliases manually (e.g., SessionServiceProvider) if using Laravel outside the full framework. For typical Laravel apps, it’s already bundled and auto-configured—no extra setup needed. The first use case is storing small, user-specific data across requests: Session::put('key', 'value'); $value = Session::get('key');. Check config/session.php (Laravel) or build your own config to set driver (file, database, redis, array, or custom).
Session::flash('status', 'Saved!') for one-time notifications (e.g., form confirmations), accessible only in the next request.Session::pull('key') to retrieve and delete in one call, or Session::increment('counter') / Session::decrement() for simple counters.SessionHandlerInterface and register via Session::extend('custom', fn() => new CustomHandler), useful for Redis, DynamoDB, or encrypted payloads.Session::put('user.preferences.theme', 'dark') or use Session::push('alerts', $message) to append to arrays.Redirect::intended()) or store previous URLs (Session::put('url.intended', Request::url())).array driver resets session data on every request—never use in production. file requires writable storage; database needs the sessions table (php artisan session:table && php artisan migrate).file or database, long-running requests block other requests for the same session. Consider Session::save() after critical writes, or switch to Redis for better concurrency.serialize()/unserialize() unless config specifies json.Session::regenerateToken()), not on every request.Session::flush() or Session::start() manually if isolation matters—Laravel clears session per test, but not always when using Session::instance().How can I help you explore Laravel packages today?