I can't log in to my Drupal site - every page says "access denied"

Published April 17, 2013

Once upon a time I updated a Drupal site and was unable to log in after the update was complete. I tried messing with the $cookie_domain and $base_url to no avail. When I used the Web Inspector or Firebug to view my Cookies I noticed I was not getting a familiar PHP Session Cookie.

Here's how to check:

  1. Chrome or Safari: right click and Inspect Element, then switch to the "Resources" tab, click "Cookies" then the domain name of your site, like "drupaleasy.com".
  2. Firebug: Open Firebug, click the "Cookies" tab (you may have to enable it first) 
  3. Firefox: Open the "Developer Toolbar" (shift+F2 or Tools > Web Developer > Developer Toolbar) and a small black bar appears at the bottom of your window. Type:
    cookie list
  4. All of the above: Open the Javascript Console and type: document.cookie

Make sure you can see a cookie that starts with SESS. Try to log in and look again.

If you don't see one, sessions are likely messed up. Try truncating your session table in your site's database.

From the sql command line:

truncate table sessions;

Everyone who is currently logged in will be logged out, but in my case I was now able to log in. Hope that helps.

If you use a graphical tool like phpMyAdmin, you can truncate a table by clicking on the box next to the "sessions" table and choosing the "Empty" option.

Sign up to receive email notifications of whenever we publish a new blog post or quicktip!