Skip to main content
Fix broken code
Source Link
Felix Eve
  • 6.3k
  • 2
  • 27
  • 57

Drupal 8 cookies can be set using ResponseHeaderBag from the Symfony\Component\HttpFoundation\Response object.

Set new cookie value

use Symfony\Component\HttpFoundation\Cookie; $cookie = new use Cookie('cookie_name', TRUE'cookie_value'); $response->headers->setCookie($cookie); return $response; 

Get cookies value

$request->cookies->get('cookie_name'); 

Drupal 8 cookies can be set using ResponseHeaderBag from the Symfony\Component\HttpFoundation\Response object.

Set new cookie value

use Symfony\Component\HttpFoundation\Cookie; $cookie = new use Cookie('cookie_name', TRUE); $response->headers->setCookie($cookie); return $response; 

Get cookies value

$request->cookies->get('cookie_name'); 

Drupal 8 cookies can be set using ResponseHeaderBag from the Symfony\Component\HttpFoundation\Response object.

Set new cookie value

use Symfony\Component\HttpFoundation\Cookie; $cookie = new Cookie('cookie_name', 'cookie_value'); $response->headers->setCookie($cookie); return $response; 

Get cookies value

$request->cookies->get('cookie_name'); 
Rollback to Revision 3 - Edit approval overridden by post owner or moderator
Source Link
avpaderno
  • 98.1k
  • 15
  • 165
  • 284

Drupal 8 cookies can be set using ResponseHeaderBag from the Symfony\Component\HttpFoundation\Response object.

Set new cookie value

use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Response;  $cookie = new use Cookie('cookie_name', TRUE); $response = new Response(); $response->headers->setCookie($cookie); return $response; 

Get cookies value

$request->cookies->get('cookie_name'); 

Drupal 8 cookies can be set using ResponseHeaderBag from the Symfony\Component\HttpFoundation\Response object.

Set new cookie value

use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Response;  $cookie = new Cookie('cookie_name', TRUE); $response = new Response(); $response->headers->setCookie($cookie); return $response; 

Get cookies value

$request->cookies->get('cookie_name'); 

Drupal 8 cookies can be set using ResponseHeaderBag from the Symfony\Component\HttpFoundation\Response object.

Set new cookie value

use Symfony\Component\HttpFoundation\Cookie; $cookie = new use Cookie('cookie_name', TRUE); $response->headers->setCookie($cookie); return $response; 

Get cookies value

$request->cookies->get('cookie_name'); 
Hello I correct things and add missing definition of $reponse.
Source Link

Drupal 8 cookies can be set using ResponseHeaderBag from the Symfony\Component\HttpFoundation\Response object.

Set new cookie value

use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Response;  $cookie = new use Cookie('cookie_name', TRUE); $response = new Response(); $response->headers->setCookie($cookie); return $response; 

Get cookies value

$request->cookies->get('cookie_name'); 

Drupal 8 cookies can be set using ResponseHeaderBag from the Symfony\Component\HttpFoundation\Response object.

Set new cookie value

use Symfony\Component\HttpFoundation\Cookie; $cookie = new use Cookie('cookie_name', TRUE); $response->headers->setCookie($cookie); return $response; 

Get cookies value

$request->cookies->get('cookie_name'); 

Drupal 8 cookies can be set using ResponseHeaderBag from the Symfony\Component\HttpFoundation\Response object.

Set new cookie value

use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Response;  $cookie = new Cookie('cookie_name', TRUE); $response = new Response(); $response->headers->setCookie($cookie); return $response; 

Get cookies value

$request->cookies->get('cookie_name'); 
Indentation
Source Link
norman.lol
  • 19.1k
  • 6
  • 75
  • 129
Loading
Source Link
bpile
  • 318
  • 3
  • 5
Loading