src/EventListener/ReferrerListener.php line 11

Open in your IDE?
  1. <?php
  2. namespace Harmonizely\EventListener;
  3. use Symfony\Component\HttpFoundation\Cookie;
  4. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  5. class ReferrerListener
  6. {
  7.     public function onKernelResponse(ResponseEvent $event): void
  8.     {
  9.         if ($event->getRequest()->get('ref')) {
  10.             $event->getResponse()->headers->setCookie(
  11.                 new Cookie(
  12.                     'ref'$event->getRequest()->get('ref'), time() + 60 60 24 14'/'
  13.                 )
  14.             );
  15.         }
  16.     }
  17. }