0

I have a Symfony 3 project that is split in 3 apps (multiple Kernels, same database, different subdomains) : Front / Admin / Partner. (Mainly did it to be able to use several Sonata Admin configs.)

When a user fill the login form in Front app, he is redirected to the corresponding app (subdomain) depending on his role.

My question is : how to make him authenticated after this redirection ?

2 Answers 2

1

I found why it was not working : my var folder was split by app therefore my sessions folder was not shared between apps.

 var
   |-- admin
   |    |-- cache
   |    |-- logs
   |    |-- sessions
   |-- front
   | ...

The solution was to define the same save_path in my apps session configs.
I also had to define the cookie_domain to hostname (without subdomain) in order to get one PHPSESSID cookie shared by all subdomains :

framework:
    session:
        save_path: '%kernel.project_dir%/var/sessions/'
        cookie_domain: 'mywebsite.com'
Sign up to request clarification or add additional context in comments.

Comments

1

To make it works i needed to add handler_id: session.handler.native_file in session section and to share session between sub domains i needed to prefix by a dot the domain in cookie_domain section:

framework:
    session:
        handler_id: session.handler.native_file
        save_path: '%kernel.project_dir%/var/sessions/'
        cookie_domain: .mywebsite.com

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.