Questions tagged [cookies]
The cookies tag has no summary.
169 questions
0 votes
1 answer
1k views
Setting a cookie
I have a drupal 10 website. I have to set a cookie for the first time the user visits the site, a cookie with a lifetime of 1 year. When the user first visits the website, the cookie is not set, a ...
0 votes
1 answer
235 views
How to dispatch a ResponseEvent so that a cookie is added after login?
I want to add a session cookie when a user logs in. The previous implementation I had, was setting the cookie in hook_user_login with this snippet: $response = new Response(); $response->headers-&...
3 votes
1 answer
129 views
Drupal unable to login and logout several accounts in a single functional test
I am trying to run some functional tests in DDEV that check functions of protected routes. I can log in the first couple of users fine, but after that drupaLogin() fails to generate a logged in ...
1 vote
1 answer
2k views
How can I read a cookie I programmatically set?
I can programmatically set a cookie in a Drupal 9 controller and I can see that cookie in Chrome's developer tools. However, I cannot programmatically get that cookie from a hook. I'm using the SAML ...
1 vote
1 answer
309 views
How do I deal with the problem of stale cookies breaking logins on a migrated site?
I just finished the migration of a D7 site into D9. Unfortunately, as I kept the same domain, before the first time I login to the new D9 site, I have to remove my domain's cookies from within my ...
2 votes
1 answer
1k views
Setting SameSite=None on a session cookie
I have a custom endpoint which stores a value in a session cookie, using this code: $session = $this->request->getCurrentRequest()->getSession(); $session->set('test.email', $data['email'])...
1 vote
1 answer
2k views
How do I change the "secure" and "httpOnly" attributes of the cookies provided by the EU Cookie Compliance module?
I am using the eu cookie compliance module in Drupal 9 and I need to change the "secure" and "httpOnly" values of the cookies, as I am getting a vulnerability error "CWE-614: ...
0 votes
0 answers
395 views
Cookie value causing a "Uncaught Error: Call to undefined function menu_get_object() " error
There are plenty of posts regarding this Drupal error, but my situation is quite odd indeed. Here's the background: I was asked to investigate an ajax error popping up on a form which does an account ...
1 vote
1 answer
552 views
Cookie authentication when reguistering users through REST API
I am running Drupal 9 commerce 2.0 as headless CMS, and I am trying to integrate the user registration/user login part of my frontend application. I was able to use the user/register REST API to ...
-1 votes
1 answer
232 views
REST cookie authentication, Post 403
I am logged in to my Drupal account and if I use the jQuery code from here then I can make a post request to my site and create a node. But if I try from another site, like my local host or a third ...
0 votes
0 answers
99 views
Make gtm.js load on start, without any cookie
I use this module and I cannot make it to load from the start gtm.js, without any cookie. If I don't load gtm.js from start, the whole Google Ads and Analitycs becomes useless. If I load gtm.js with ...
0 votes
2 answers
4k views
Cannot Login, error msg shows "To log in to this site, your browser must accept cookies from the domain"
On my dev environment hosted on the cloud which has SSL, I added this to the settings.php $secure = true; // if you only want to receive the cookie over HTTPS $httponly = true; // prevent JavaScript ...
1 vote
1 answer
327 views
Unable to use SameSite=none with secure attribute, using Symfony\Component\HttpFoundation\Cookie to create the cookie
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 ...
0 votes
2 answers
449 views
The sequence of actions upon cookie-authentication to Drupal site
There is a drupal 9 site that has a REST-endpoint that can be accessed for logged-in users (not for anonymous ones). And, it's necessary to make a GET request to the endpoint using cookie ...
0 votes
1 answer
88 views
We need to check for and capture a URL parameter that may on any page so we need a efficient way to do this?
We need to track some anonymous users coming to the site with a URL parameter, like "?utc=1234". This could be on any page though so I don't know what the most resource-efficient way to ...