Score:0

Cannot Login, error msg shows "To log in to this site, your browser must accept cookies from the domain"

cn flag

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 access to session cookie
$samesite = 'none';

if(PHP_VERSION_ID < 70300) {
  session_set_cookie_params($maxlifetime, '/; samesite='.$samesite, $_SERVER['HTTP_HOST'], $secure, $httponly);
} else {
  session_set_cookie_params([
    'lifetime' => $maxlifetime,
    'path' => '/',
    'domain' => $_SERVER['HTTP_HOST'],
    'secure' => $secure,
    'httponly' => $httponly,
    'samesite' => $samesite
  ]);
}

My goal was to set SESSION cookie to samesite = 'NONE'.

Login was working when I did this on Drupal 8, but now on Drupal Core 9.3.0, when I login I get error message "To log in to this site, your browser must accept cookies from the domain [domain_name]"

enter image description here

leymannx avatar
ne flag
My first take would be to search this string. Then you know the place in core where it comes from, and when. Then you can compare the code at this place to Drupal 8 on https://git.drupalcode.org.
berliner avatar
bd flag
Does this help? https://www.drupal.org/project/drupal/issues/2946 It's the issue where that error message has been introduced.
berliner avatar
bd flag
Are cookies disabled in your browser by any chance?
Gabriel Fernandez avatar
cn flag
@berliner thanks, but haven't found out anything useful from the issue. Also cookies are enabled in my browser.
Vik Durve avatar
us flag
Did you find any solution ? My Drupal version is 9.5.9, dev & live website which are running on server, there I am able to login, but I am facing this issue on my local setup, I can login in Firefox incognito mode, but apart from that in all browser I am facing this issue, even in incognito mode.
Score:0
cn flag

You get this error message when Drupal expects there to be a session, communicated by the check_logged_in, but none can be found.

I've found myself in this situation myself when a miss-configured web server stripped the cookies from the request.

The leads to Drupal setting up the session, and adding the query parameters, but the cookie not being present in subsequent requests. Drupal then displays the

your browser must accept cookies

message.

Likely the cookie settings you are adding cause the cookie to become invalidated somehow, so double check that the browser actually sends the cookies, and that they reach Drupal.

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.