Logging the User Out of Your Application

Problem

You want to log the user out.

Solution

Use the Auth::logout() method.

Auth::logout();

This will clear the user from memory and any session storage of the user will be cleared also.

Discussion

This files the auth.logout event.

You can listen for it. Here's an example that logs when the user logs out.

Event::listen('auth.logout', function($user)
{
    $message = sprintf('User #%d logged out', $user->id);
    Log::info($message);
});
comments powered by Disqus