Session Helpers
session()
function session(?string $adapter = null): Session
Use this as the standard entry point for session operations.
session()->set('locale', 'en');
$locale = session()->get('locale');
Pass an adapter name only when you explicitly need one:
session('database')->set('cart_id', 'abc123');
Helper behavior
- no adapter passed → uses
session.default - adapter passed → resolves that backend (
nativeordatabase) - returns a Session wrapper, not a raw adapter
- reuses the same wrapper for repeated calls to the same adapter in the current process
Prefer backend setup through configuration, then call session() from application code.