Laravel Sessions Middleware
ASecurityAssuming `SecurityHeaders` exists at `app/Http/Middleware/SecurityHeaders.php`, register it globally in `bootstrap/app.php`: ```php <?php use App\Http\Middleware\SecurityHeaders; use Illuminate\Foundation\Application; use Illuminate\Foundation\Configuration\Middleware; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( web: __DIR__.'/../routes/web.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware): void {...
- 584 stars
- 0 votes
- 0 copies
- 3 views
- Added September 5, 2026
Security analysis
100/100Pro scans all 18 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill laravel-sessions-middleware --agent claude-codeAre you the author of Laravel Sessions Middleware?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-laravel-sessions-middleware-abbf7b9c)Assuming `SecurityHeaders` exists at `app/Http/Middleware/SecurityHeaders.php`, register it globally in `bootstrap/app.php`:
```php
<?php
use App\Http\Middleware\SecurityHeaders;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Middleware;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware): void {
$middleware->append(SecurityHeaders::class);
// Use prepend() when this middleware must run at the highest priority.
// $middleware->prepend(SecurityHeaders::class);
})
->withExceptions(function ($exceptions): void {
//
})
->create();
```
`SecurityHeaders` should add HSTS, CSP, `X-Frame-Options`, and `X-Content-Type-Options`. Keep the middleware lightweight, cheap and deterministic; avoid heavy computation in the global pipeline. Use Redis in scaled production to avoid file-session I/O and locking problems, and regenerate the session after login to prevent session fixation.
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- eval-4.baseline.md
- eval-4.with-skill.md
- eval-5.baseline.md
- eval-5.with-skill.md
- eval-6.baseline.md
- eval-6.with-skill.md
- trigger-1.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
- trigger-5.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.