1

Drupal 7.56 and CiviCRM 4.7.27

I have a site that uses very few add-ons (Views and Chaos tools in Drupal, API csv import in CiviCRM), and a few word replacements with the Grant module. Otherwise, it's an out-of-the-box set up.

Users are frequently logged out for no obvious reason. It's not the same action that triggers it so I can't pin it down to a particular error. My error logs showed a theme hook error but I've switched to a different theme and still not resolved the issue.

My recent log messages look like this (ignore the 'login attempt failed'): enter image description here

And my top 'Access Denied' errors look like this enter image description here

  • 1
    Do you have some pages accessed by http and some by https ? – Aidan Jan 8 '18 at 16:53
  • Are you using same database for civicrm and drupal or separate database for each? – Prem Patel Jan 8 '18 at 19:41
  • It should all be https but I've not forced it in the htaccess file (I usually do but when I reinstalled this site I tried to keep it as simple as possible). I will edit that today to make sure that's not part of the problem. – Rose Lanigan Jan 9 '18 at 14:24
  • I'm using the same database for both. I've been discussing this recently with another implementer - is it good practise to use separate dbs for each, and if so, why? – Rose Lanigan Jan 9 '18 at 14:25
  • One db or two - that's worth a question in its own right! – Aidan Jan 9 '18 at 17:23
1

One explanation is that, rather than being logged out of the site, your users are being moved from a site they are logged into to one that they aren't logged into. If your site is served via https://www.example.org, you might see users "suddenly be not logged in" when they visit any of the following:

  • https://example.org, or
  • http://example.org, or
  • http://www.example.org

If your CMS site isn't configured to "lock in" a specific canonical URL (including protocol and hostname), CiviCRM may bounce people from another URL which they are logged into over to the URL CiviCRM thinks is "correct" (per CiviCRM's civicrm.settings.php). When this happens, the user experience is that they get logged out (but they will then be mysteriously logged back in if they visit the URL they were logged in on before).

Drupal isn't fussy about having a canonical URL, but CiviCRM is, and it's good practice anyway.

If this is the behaviour you're seeing, your best bet is to configure your CMS / webserver / .htaccess to enforce a canonical URL (single hostname and protocol), so that all visitors to alternate URLs are immediately moved over to the preferred / canonical base URL.

  • Thanks @chris-burgess I did this initially, before I rebuilt it the first time, and it was still logging out. I'm not convinced this is the fix but I will set it to avoid it complicating matters. – Rose Lanigan Jan 10 '18 at 9:22
  • So, I edited the htaccess file, I tested it to make sure it wouldn't allow me to load a http page, and it's working. And then it's just logged me out again. – Rose Lanigan Jan 10 '18 at 12:49
  • The URL CIVICRM_UF_BASEURL in civicrm.settings.php needs to match your site's canonical base URL (noting that CiviCRM requires you to append a / and Drupal's settings.php requires you not append a /) - make sure that all lines up. – Chris Burgess Jan 11 '18 at 3:54
  • The civicrm.setting.php file was correct, the drupal settings file was commented out so I've uncommented it and edited it to match the URL (without the / in this case) but I'm guessing this won't make much difference because it's already set in the htaccess file? – Rose Lanigan Jan 12 '18 at 10:15
  • It's sounding like this isn't the solution for you sorry Rose! If this was the problem, you'd see your browser changing URLs when it happened. – Chris Burgess Jan 12 '18 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.