<?php
/**
* This file is part of the Pimcore X Installation by
* ercas GmbH & CO. KG <https://www.ercasdieagentur.de>
*
* @license GPLv3
*/
namespace App\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* Adds remember-me cookies to the Response.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*
* @final
*/
class ResponseListener implements EventSubscriberInterface
{
/**
* This attribute name can be used by the implementation if it needs to set
* a cookie on the Request when there is no actual Response, yet.
*/
public const COOKIE_AFTER_NAME = '_security_remember_me_cookie';
public const COOKIE_BEFORE_NAME = 'REMEMBERME';
public function onKernelResponse(ResponseEvent $event)
{
if (!$event->isMainRequest()) {
return;
}
$request = $event->getRequest();
$response = $event->getResponse();
if ($request->cookies->get(self::COOKIE_BEFORE_NAME)) {
if(!$request->cookies->get(self::COOKIE_AFTER_NAME)) {
/* setcookie(
self::COOKIE_AFTER_NAME,
$request->cookies->get(self::COOKIE_BEFORE_NAME),
time()+36000, //10 hours
'',
'',
true,
false
); */
}
//check if already exist // delete REMEMBERME
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
return [KernelEvents::RESPONSE => 'onKernelResponse'];
}
}