Clone session cookie for another domain in Symfony2

I am looking for a working solution to set a secure session cookie clone for another domain in a different Symfony2 environment. My idea is to set the cloned cookie right after the user logs in, so that the user can authenticate in two different Symfony2 environments on two different domains.

Domain: mysite-a.com        // Environment -e site
Domain: api.mysite-b.com    // Environment -e api

Where to find something like a controller or event (the best solution) to connect?

I am using the latest version 2.x.dev FOSUserBundle.

I know this configuration is pretty ugly. Unfortunately, I am not allowed to change the domain configuration from api.mysite-b.comto api.mysite-a.com(e.g. wildcard cookies).

+3
source share
1 answer

, , PHP $domain

bool setcookie ( string $name [, string $value [, int $expire = 0 [, string $path [, string $domain [, bool $secure = false [, bool $httponly = false ]]]]]] );

symfony2 Cookie:

use Symfony\Component\HttpFoundation\Cookie;

$response->headers->setCookie(new Cookie('foo', 'bar'));

cookie , PHP:

public function __construct($name, $value = null, $expire = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true)

,

0

All Articles