i have 2 symfony projects project 1 and project 2 and want to authenticate in both using the login form in project 1. both projects have the same database my projects hostnames are for example project1.test and project2.test they are not in the same domain
i tried sharing session in the database and using PDOsession handler
session:
handler_id: Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\PdoSessionHandler
save_path: '%kernel.project_dir%/var/sessions'
cookie_secure: auto
cookie_samesite: lax
but i could not find a way to get that session in the second project i'm not sure how i can do that
it was possible to use subdomaines so i ended up sharing session in mysql for both projects and configure the same cookie_domaine and trusted domaines on both projects in framwork.yaml
session:
handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
cookie_secure: auto
name: shared_session
cookie_domain: '.example.com'
cookie_lifetime: 0
gc_maxlifetime: 86400 # Set the desired TTL in seconds
gc_probability: 1
trusted_hosts: ['product.example.com', 'cart.example.com']
setting cookie_lifetime to 0 allows you to use gc_maxlifetime instead i hope this is helpful to someone <3