-
-
Save anonymous/88e52bd7876378b0f490ed15d30b43fe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; | |
use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; | |
use Symfony\Component\HttpFoundation\Session\Session; | |
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; | |
use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; | |
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; | |
use Symfony\Component\HttpFoundation\Response; | |
use Symfony\Component\HttpFoundation\Cookie; | |
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory; | |
use Zend\Diactoros\Response\SapiStreamEmitter; | |
require dirname(__DIR__) . '/vendor/autoload.php'; | |
$factory = new DiactorosFactory(); | |
$sessionHandler = new NativeFileSessionHandler(); | |
$sessionMetadataBag = new MetadataBag('_sf2_meta', '0'); | |
$sessionStorage = new NativeSessionStorage(['cookie_httponly' => true, 'gc_probability' => 1], $sessionHandler, $sessionMetadataBag); | |
$session = new Session($sessionStorage, new AttributeBag(), new FlashBag()); | |
$session->start(); | |
$foundationResponse = new Response(); | |
if (isset($_GET['set_cookie'])) { | |
// emulate Symfony authentication | |
$session->migrate(true); | |
// emulate Symfony rememberme | |
$foundationResponse->headers->setCookie(new Cookie('REMEMBERME', 'value', time() + 123456, '/', $_GET['set_cookie'])); | |
} | |
$response = $factory->createResponse($foundationResponse); | |
$emitter = new SapiStreamEmitter(); | |
$emitter->emit($response); | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment