How to programmatically login/authenticate a user?
Yes, you can do this via something similar to the following: use Symfony\Component\EventDispatcher\EventDispatcher, Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken, Symfony\Component\Security\Http\Event\InteractiveLoginEvent; public function registerAction() { // … if ($this->get(“request”)->getMethod() == “POST”) { // … Do any password setting here etc $em->persist($user); $em->flush(); // Here, “public” is the name of the firewall in your security.yml $token = new UsernamePasswordToken($user, $user->getPassword(), “public”, $user->getRoles()); … Read more