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 8433537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:24:48+00:00 2026-06-10T06:24:48+00:00

Using Symfony2 I want to augment the security.content user after login with information obtained

  • 0

Using Symfony2 I want to augment the security.content user after login with information obtained after login.

So in the login success code I do the following in AccountController:

$user = $this->get('security.context')->getToken()->getUser();

// Get everything we'll ever need for this user
$user->fillDetails($this, $this->container);

$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());

// Give it to the security context
$this->container->get('security.context')->setToken($token);

return $this->redirect($this->generateUrl('AccountBundle_homepage'));

If I immediately retrieve the user again after calling setToken() this information that is set in the User object in fillDetails() is still present.

However in the controller action for AccountBundle_homepage when I get the user using

$user = $this->get('security.context')->getToken()->getUser();

The extra information I set in fillDetails() is no longer there, or 0.

Any help appreciated.

  • 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-10T06:24:49+00:00Added an answer on June 10, 2026 at 6:24 am

    The security context creates a token on each request, that means you can’t modify a token, redirect the user and expect getting data set on the previous token. If you don’t persist your user, it won’t work. The user is reloaded on each request too.

    You can find more information about the token here: http://symfony.com/doc/current/cookbook/security/custom_authentication_provider.html#the-token

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

Sidebar

Related Questions

I'm using Symfony 2 security system. When some user trying to login, I want
I want to practise using services in Symfony2. To practise I want to implement
I'm using Symfony2 Framework, and I want to update an entity with data from
I'm using symfony2. I have a form, and I want to print it a
I want to upload a text file received via AJAX request in Symfony2 (using
I'm using Symfony2 Framework, and this is what I want to do: I want
I am an experienced Symfony user and have started using Symfony2 and absolutely love
I'm using the symfony2 framework and I want to use the PHP's DateTime class
I'm using the standard authentication mechanism of Symfony2 and I want to let the
I have a form in Symfony2 and I want to give the user an

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.