-
How is the /logout route provided expected to be used? Using an Are you intended to create a new route and POST from there? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @Epzillon, The reason why the According to the HTTP specification, As browsers can prefetch URLs, users may accidentally be logged out if the By only supporting Additionally, by using the Here is an example of how you can log out a user with a link through the <form method="POST" action="{{ route('logout') }}">
@csrf
<a href="{{ route('logout') }}" onclick="event.preventDefault(); this.closest('form').submit();">
{{ __('Log Out') }}
</a>
</form> You can also check Logout: GET or POST? for more information on this topic. |
Beta Was this translation helpful? Give feedback.
Hello @Epzillon,
The reason why the
/logout
route doesn't support theGET
method by default is because logging out of an application involves modifying the user's session data, which is considered a state-changing operation.According to the HTTP specification,
GET
requests are intended to be used for retrieving resources without modifying their state, while POST requests are intended for state-changing operations.As browsers can prefetch URLs, users may accidentally be logged out if the
GET
method is used.By only supporting
POST
requests, the/logout
route ensures that logging out of the application can only be performed through a state-changing operation, which helps to prevent accide…