Yikes! A client's site suddenly turned up "Access Denied" for admins – up, down, and all around. Attempts to log in as almighty User ID 1 would simply spit the login screen right back again, or appear to "take" momentarily, yet return "Access Denied" for any following admin action.
Some horrible flub-up with user permissions? Can't even check and troubleshoot when the site won't let the admin in! And playing with cache, cookies, and other browser fiddly bits wasn't doing the job.
Question answer:
I expected major pain to result. But a search of the Drupal site quickly turned up this gem:
http://drupal.org/node/6696#comment-198054
Just a little addition to my INDEX.PHP file. I tried it, and Huzzah! Back in logged-in action.
The cause of the problem? Perhaps this:
http://drupal.org/node/6696#comment-204960
Hmm, could it be that the ISP had updated PHP from 4 to 5? Yes, it seemed so! (Maybe now I'll start to pay attention to their newsletters.)
So the thread addressed my woe, and I'm a happy Drupaller all over again. Now, this particular case had a Drupal 4.x site knocked out of action by a PHP upgrade, so it may not apply directly to many users' situations. But if you're getting "Access Denied" hate (on 4.x or 5.x), give the linked thread a peek.
My thanks to everyone offering help on the topic, especially Drupal Gods kweisblatt and johnchalekson!
do not not forget to check the sessions table
same problem, different issue ! my sessions table was the problem. Check if you have no error message there and if so delete it and replace with a new one.I came accros this issue some weeks after moving to a new server. Drupal 5.
FIXED THIS FOR ME!
This one was my fault - I'd changed the domain for a site that I'd built and didn't change the $cookie_domain line of settings.php to reflect this.
After changing this line to the correct domain it now logs me in fine!
Don't forget settings.php
Heh. I think I've finally gotten good at checking and editing settings.php as needed, but in the past, I couldn't count how many times I've made the same kind of oversight you describe.
Semi-tangential comment: For typical computer users like me, coming from a GUI world, Drupal's been quite the introduction to configuration files and (occasional) command lines. Those methods can seem awfully futzy to those of us raised on neat GUI tools, but more and more Drupal is teaching me the power of The Old Ways. : )
this is very valuable
this is very valuable information i didn'y how to fix it thanks for sharing this :)
Using CKEditor? Your problem could be $cookie_domain
I had this problem and none of the solutions about or on Google fixed it. In my case, I was using CKEditor and there were three domains which could point to the site. In the Drupal settings.php file, there's a line which starts
$cookie_domainsome features of CKEditor require this, but it meant that when I accessed the site on a domain different to the one set here, I got 'access denied' even when logging in as admin.
To fix this, I set some redirects in the .htaccess file so that all access to the website would come through the one, authorised domain. Job done.
I had commented out this code
I had commented out this code but still it give errors.What i do?
Thanks! This solved the
Thanks! This solved the problem for me. I commented out the $cookie_domain URL and I was able to log in again.
Thanks a lot for sharing. You
Thanks a lot for sharing. You have done a brilliant job. Your article is truly relevant to my study at this moment, and I am really happy I discovered your website. However, I would like to see more details about this topic.
great job on the blog man.
great job on the blog man.
Had the same issue and not fixed it...help me please
My site has been running fine for a years, then all of a sudden I can't login under any username, even SuperAdmin. Entered username and password and it cycles back to the Homepage. Asked for a new password and followed the email link, again cycles back to the Homepage...
that's happen after i added a google ajax search module but i cancel for used it...and after disable that's module i want to create block but caould not....and then i log out....after that i want to LOGIN and add some posting but after i fiil in username and password...I can't login and it cycles back to the homepage...
I empthy cache on database and browser...but can't solve the problem.....i used opera, chrome and mozilla also can't solve the problem until now.
I have 2 website with the same problem and used Drupal v5.1.2 and v4.7
my website is : http://freewareshare.net and http://wirediagram.net Any suggestions ???
Thank you for your answer...
I really appreciated :)
Greetings
Can't log in to Drupal site
I missed your comment and this is probably much too late a reply to do you any good... But what I'm not sure of from your message is whether or not you're able to disable modules that may be causing the problem. If you are unable to disable modules because you can't log in, you could try to Disable a module from within database.
reading blog posts is a lot
reading blog posts is a lot like a life experience, it seems like the more I read the more I realize I don't know as many things as I thought. thanks for sharing ;-) and thanks to the impact of the internet!
If this didn't fix it.
I had this problem and I tried the fix running 5.7. It wasn't throwing the correct error. I found that the sessions table was corrupt. If you look in the logs you will find
Error - Can't open file: 'sessions.MYI'
Check and see if you can select from the sessions table. If not, then run
sql>repair table session;
FIXED
Great tip, thank you. That
Great tip, thank you. That solved it for me.
Fixing "access denied"
Thanks! I can't verify the method for myself – I don't have 5.x running anywhere now, and am not currently experiencing the issue either – but your comment may be a big help to others.
There are many possible causes for access errors of all types. Good to have a big toolbox of potential fixes to try,
It worked
adding $GLOBALS['tempUser'] = $user; worked but I find it worth noting that I had to delete cookies first
Deleting cookies
Good point; thanks! Deleting cookies and/or caches, depending on the problem at hand, is a part of solutions that often gets overlooked.
Same problem
I have the same problem. Did you find any solution?
Thanks,
Homa
Yes, a fix
If I recall correctly: Per the link in the article, adding
to the end of the index.php file did the trick. That was Drupal 5.x for me, though, long ago, and concurrent with an upgrade from PHP 4 to 5 by my webhost. So it may be a useful fix for you, if you happen to be under those same conditions.
Re: How to fix "Access Denied" for admins?
Didn't do it for me.
I can log in as user 1, but gets access denied to all the admin-stuff..
Faced the "Access Denied" for admins twice!
I don't know, for all of you, but for me even after adding "$GLOBALS['tempUser'] = $user;" at the end of index.php file, nothing changed. The first time the problem occured, I recreated quickly the platform, thinking that I had done surely a bad administrative operation on the plateform. Then, the problem reappeared again, on that new one! Now I'm stuck!
What's going on? I'm using Drupal commons, to build my platform! And even the cron task failed after enabling some modules related to the instant chat.... I'm going crazy!!! Help please...
Re: How to fix "Access Denied" for admins?
Ack, that kind of thing is frustrating as heck. I imagine there are many, many little ways that an installation can get screwed up and deny access.
The best immediate step you can take is to throughtly search the Drupal.org forums for more possibilities, and beg for help if nothing good turns up. All of which you've probably already done... : (
Re: How to fix "Access Denied" for admins?
Thank you! My ISP just upgraded their default PHP installation to 5 on 1-1-08. Thank you for sharing this.
Post new comment