Score:1

Unable to use SameSite=none with secure attribute, using Symfony\Component\HttpFoundation\Cookie to create the cookie

sl flag

I am trying to create a cookie in Drupal 8.9 with SameSite=none with secure attribute, using the Symfony\Component\HttpFoundation\Cookie class but I am unable to do so as the class doesn't allow the secure attribute along with none.

Also, I tried setting the Cookie's secure parameter to TRUE but it results in infinite redirects in my site. I don't want to implement the solution on site level as it will affect other cookies capabilities. I just want to do this for one particular cookie I am creating.

$cookie = new Cookie(self::SIGMACOOKIENAME, TRUE, 0, '/', NULL, TRUE, FALSE, TRUE, self::SAMESITE_NONE); 
Score:1
us flag

If you're setting SameSite=None, you'll need to set the Secure attribute for HTTPS.

If SameSite=None is set, the cookie Secure attribute must also be set (or the cookie will be blocked). https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite#none

Sharique Husain avatar
sl flag
Yes, if I set the `Secure` attribute then my site results in infinite redirects.
us flag
That’s the issue then, you’ll need to fix your site to work with HTTPS. For example, with letsencrypt.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.