Skip to content

Instantly share code, notes, and snippets.

View juneodev's full-sized avatar

CUNEO Jérémie juneodev

  • Juneo.dev | JKJ-DEV
  • Marseille FRANCE
  • 11:19 (UTC +02:00)
View GitHub Profile
@azhararmar
azhararmar / Symfony - Manual User Authentication
Last active October 1, 2025 19:14
Manually Authenticate User In Symfony
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
// Manually authenticate user in controller
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$this->get('security.token_storage')->setToken($token);
$this->get('session')->set('_security_main', serialize($token));