You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
825B

  1. <?php
  2. namespace Lc\SovBundle\Component;
  3. use Lc\SovBundle\Resolver\UrlResolver;
  4. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  5. class CookieComponent
  6. {
  7. protected UrlResolver $urlResolver;
  8. protected ParameterBagInterface $parameterBag;
  9. public function __construct(UrlResolver $urlResolver, ParameterBagInterface $parameterBag)
  10. {
  11. $this->urlResolver = $urlResolver;
  12. $this->parameterBag = $parameterBag;
  13. }
  14. public function getCookieDomain()
  15. {
  16. return ($this->urlResolver->isServerLocalhost()) ? null : $this->parameterBag->get('app.cookie_domain_distant');
  17. }
  18. public function cryptCookie($data)
  19. {
  20. return base64_encode($data);
  21. }
  22. public function decryptCookie($data)
  23. {
  24. return base64_decode($data);
  25. }
  26. }