← PHP / Laravel · Contents

PHP-084 / Intermediate

Handling logout with GET (CSRF)

A01:2021 Broken Access Control · CWE-352 CSRF

Why is this a problem?

<img src="/logout"> can force a logout.

How to fix it

php
Route::post('/logout', [AuthCtrl::class, 'logout']);   // Include @csrf in the form

Further reading