Can't log in as admin (or anything else)

Can't log in as admin (or anything else)

by Paul Johnson -
Number of replies: 13

I've just installed 1.4.3+ (many times) on a red hat server with mysql, php 4.3.4 (here's the info) & apache 2.  All has worked fine except when I try the initial login with admin it just flips back to login screen and says you are not logged in. 

I can add a new account.  When I confirm the account it says I7m logged in but if I click courses I get logged out again.

I have tried adding another admin user to mysql with the same results. 

I can't see any messages in the logs to suggest where the problem is. 

I've been getting this problem with 1.4.2 as well.

Any help really appreciated as I'm supposed to be running course on this next week!

Thanks

Average of ratings: -
In reply to Paul Johnson

Re: Can't log in as admin (or anything else)

by Brian Koontz -
Paul, do you have cookies enabled?  If so, have you verified that a cookie is being set?  This is a frustrating problem because there is no error message to indicate that cookies aren't set...you simply get sent back to the login screen.

  --Brian
In reply to Brian Koontz

Re: Can't log in as admin (or anything else)

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
If someone can tell me how to detect when cookies aren't enabled in a browser I'll add it.
In reply to Martin Dougiamas

Re: Can't log in as admin (or anything else)

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Detect cookie support?

Set cookie during first visit to login/index.php (if not already present) and check it after form submission. It would need only a small tweaking in login/index.php. I did not test it, but IMHO it should work.

I do not know if it is possible to set cookie with value "", but we could use some special username to indicate nobody logged in before...


I dit try it - WFM, here is a diff for login/index.php
In reply to Petr Skoda

Re: Can't log in as admin (or anything else)

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Excellent, thanks!  I'll put that straight into 1.5 with a message to tell people what the problem is.
In reply to Martin Dougiamas

Re: Can't log in as admin (or anything else)

by Petr Skoda -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
    if ($frm and (get_moodle_cookie() == '')) {    // Login without cookie

        $errormsg = get_string("cookiesnotenabled");

    } else if ($frm) {                            // Login WITH cookies

        if (get_moodle_cookie() == '') {
            error('Cookies not working!');
            die;
        }

        $frm->username = trim(moodle_strtolower($frm->username));


... seems redundant to me wink
In reply to Petr Skoda

Re: Can't log in as admin (or anything else)

by Paul Johnson -
is it possible there is some server side security that prevents the cookie from being set correctly? how could I check that the cookie has been set correctly? there is a cookie but i can't tell if it's correct. from konqueror it looks like
name MOODLEID_
value %25E2%25C8%2513E%25BD
domain blank
path /
secure no
In reply to Paul Johnson

Re: Can't log in as admin (or anything else)

by Paul Johnson -
yep, the problem was cookies.  session.use_cookies was set to off.  overrode it in htaccess and moodle fired up fine. 
it then knocked over the web server but that's another story
In reply to Brian Koontz

Re: Can't log in as admin (or anything else)

by Paul Johnson -

Brian, thanks. I thought it might have been something like that (it certainly is behaving this way) and tried konqueror, firefox, and IE, messing with what ever cookie like variables I could find but no joy. 

Any other ideas?

Cheers

 

In reply to Brian Koontz

Re: Can't log in as admin (or anything else)

by Paul Johnson -
I've checked again and there is a cookie but...what do you mean by being set?  
In reply to Paul Johnson

Re: Can't log in as admin (or anything else)

by theo leenders -
  If you log in as admin en then open your browser with
www.yoursite/admin  ? I have the problem that i can't log in as admin once in a while so i dont think it is the cookies...  This works for me but i think there is a bug

theo

In reply to theo leenders

Re: Can't log in as admin (or anything else)

by Paul Johnson -
sorry theo, what do you mean by admin en?
In reply to Paul Johnson

Re: Can't log in as admin (or anything else)

by theo leenders -
log in and than browse to
www.yoursite/admin    thats all.
en is and in Dutch so ...

gr theo