The postLogin hook is triggered after a user has logged in. This can be either in the back end or the front end. It passes the user object as argument and does not expect a return value.

Using the postLogin hook has been deprecated and will no longer work in Contao 5.0.


  1. \Contao\User $user

    The back end or front end user (object) which has been logged in.


// src/EventListener/PostLoginListener.php
namespace App\EventListener;

use Contao\CoreBundle\ServiceAnnotation\Hook;
use Contao\User;
use Terminal42\ServiceAnnotationBundle\ServiceAnnotationInterface;

class PostLoginListener implements ServiceAnnotationInterface
     * @Hook("postLogin")
    public function onPostLogin(User $user): void
        if ($user instanceof \Contao\FrontendUser) {
            // Do something with the front end user $user