How To Log In After Receiving An Access Denied Message In Drupal 7

Problem

  • The problem we've discovered occurs after a new Drupal 7 install. Instead of being automatically logged in (which is usually the case) we were redirected to the front page.
  • Upon seeing the user login block - we enter our administration credentials.
  • The page refreshed and we were hit with an "Access Denied" message.

Attempts

  • Firstly, we checked the .htaccess - no discrepancies to report.
  • We then opened .settings.php file, searched for "$cookie_domain" and commented out that line (which was done for us by default). - Same error message. 

After the few attempts yielding no results we dug deeper into the issue. What we found that the cookies stored within the browser sessions were not working as they were intended to. 

Solution

Using Chrome:

1. Right click and Inspect Element.

2. Click the "Resources" tab

3a. Locate "cookies" 

3b. Expand cookies tab

3c. Click on your Site (it should be your site URL or server name if you are on a local server)

4. Locate the cookie sessions. Usually the cookie sessions will start with "SESS". If you do not see this in your cookies you might have to truncate your session table in your site's database:

truncate table sessions;

5. Right click the SESS cookie and select delete

6. Log back in.

After performing these steps I was able to log in and use the admin credentials as I normally do.