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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:05:39+00:00 2026-06-18T11:05:39+00:00

In order to implement cross application authentication (getting logged in in my Symfony2 app

  • 0

In order to implement cross application authentication (getting logged in in my Symfony2 app if the user already logged in in an other application), I made a Symfony2 listener class that checks if specific data concerning the user is in the session. This data comes from a non-Symfony2 (but PHP) app.

The problem is that the session data from the other app is not present in the session object I use in my class.

Here is the listener (simplified) class:

<?php
class OldAppAuthenticationListener
{
    /** @var \Symfony\Component\Security\Core\SecurityContext */
    private $context;

    public function __construct(SecurityContext $context)
    {
        $this->context = $context;
    }

    public function onKernelRequest(GetResponseEvent $event)
    {
        if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
            // don't do anything if it's not the master request
            return;
        }

        if (!$this->context->isGranted('IS_AUTHENTICATED_FULLY')) {
            $request = $event->getRequest();
            $session = $request->getSession();

            $userName = $session->get('nomUtilisateur');

            $token = new PreAuthenticatedToken($userName, null, 'secured_area', array('ROLE_USER'));

            $session->set('_security_secured_area',  serialize($token));
        }
    }
}

It is registered in services.yml like this:

services:
    my_app.listener.old_app_authentication:
        class: Acme\MyAppBundle\Listener\MyAppAuthenticationListener
        arguments: ["@security.context"]
        tags:
            - { name: kernel.event_listener, event: kernel.request }

But the $session->get('nomUtilisateur') always returns NULL (and $session->all() and $_SESSION only return some Symfony2 specific vars) although the other app stores all this data in the session.

Of course, I use the same cookie session domain for both apps (as configured in config.yml) and I can easily check that the PHPSESSID is the same.

So here is my question: why are the old app session variables not available and how can I get them from my listener class?

  • 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-18T11:05:41+00:00Added an answer on June 18, 2026 at 11:05 am

    As stated here, Symfony2 uses session bags to store session stuff. This means that you have to directly access the $_SESSION superglobal for such a functionality.

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

Sidebar

Related Questions

I wanted to implement a default sort order in my domain class and immediately
I'm looking to implement a warning if the user attempts to leave the order
How do i implement a java comparator class which can sort the order of
In order to implement auto-vivification of Ruby hash, one can employ the following class
I am using the EGOTableViewPullRefresh library in my iOS app. In order to implement
do you know any application beside pattern recog. worthe in order to implement Hopfield
I was wondering how exactly does TCP implement in-order delivery. lets say this is
I need to implement a plugin architecture within c#/.net in order to load custom
I'm trying to implement a custom SimpleCursorAdapter in order to switch out layouts in
I am trying to implement Supersized slider with my Yii project. In order 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.