Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8996441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:45:19+00:00 2026-06-15T23:45:19+00:00

I have created a security.authentication.success event listener, which should send a line to the

  • 0

I have created a security.authentication.success event listener, which should send a line to the logs upon login success. Now every time I load a page which is behind a firewall, I get a successful login message in my logs. If I tried to use

if ($this->container->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY'))
{
    $logger->info('Successful login by ' . $username);
}

I get into a recursive madness (xdebug complaining after 10000 nested calls, or whatever high I set it to).

Is there a way to check if the user has just logged in, or if (s)he is using an active session?

Note: I’m using Symfony 2.2 (dev-master)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:45:20+00:00Added an answer on June 15, 2026 at 11:45 pm

    You have to use the security.interactive_login:

    namespace Acme\UserBundle\Listener;
    
    use Symfony\Component\EventDispatcher\Event;
    use Symfony\Component\Security\Core\SecurityContext;
    use Doctrine\Bundle\DoctrineBundle\Registry as Doctrine; // for Symfony 2.1.x
    // use Symfony\Bundle\DoctrineBundle\Registry as Doctrine; // for Symfony 2.0.x
    
    /**
     * Custom login listener.
     */
    class LoginListener
    {
        /** @var \Symfony\Component\Security\Core\SecurityContext */
        private $securityContext;
    
        /** @var \Doctrine\ORM\EntityManager */
        private $em;
    
        /**
         * Constructor
         * 
         * @param SecurityContext $securityContext
         * @param Doctrine        $doctrine
         */
        public function __construct(SecurityContext $securityContext, Doctrine $doctrine)
        {
            $this->securityContext = $securityContext;
            $this->em              = $doctrine->getEntityManager();
        }
    
        /**
         * Do the magic.
         * 
         * @param  Event $event
         */
        public function onSecurityInteractiveLogin(Event $event)
        {
            if ($this->securityContext->isGranted('IS_AUTHENTICATED_FULLY')) {
                // user has just logged in
            }
    
            if ($this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
                // user has logged in using remember_me cookie
            }
    
            // do some other magic here
            $user = $this->securityContext->getToken()->getUser();
    
            // ...
        }
    }
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an Attribute, call MyAttribute, which is performing some security and for
I am a WCF / Security Newb. I have created a WCF service which
I'm making a web application in which certain pages are login-protected. I have created
I have created a spring security Filter as below. <!-- Enables Spring Security -->
Hi stackoverflow friends, I have an instance that ,In symfony2 I created a security
Maybe this isn't possible due to Security implications... I have a Deployment Package created
In my website, I am not using any authentication or authorization. I've created login
I have a repository created with TortoiseSVN. This repository has configured security as this:
I have an ASP.NET 4.0 application within which I need to forward the authentication
I have created a Security Token Service (STS), an service with a reference to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.