You are already logged in as [...], you need to log out before logging in as different user.

You are already logged in as [...], you need to log out before logging in as different user.

by Brendan Abolivier -
Number of replies: 4

Hi there,

I'm writing an authentication plugin for Moodle using Macaroons. Its source code is available here (don't mind the code quality, it's more a proof of concept than anything else, and I'll clean the code later).

I have an issue with this plugin: while the authentication works, when I access login.php, I get the "You are already logged in as [...], you need to log out before logging in as different user" error message. It seems that the authentication happens twice, but I don't see how.

What did I get wrong?

Thanks in advance for your answers!

Average of ratings: -
In reply to Brendan Abolivier

Re: You are already logged in as [...], you need to log out before logging in as different user.

by Brendan Abolivier -

OK, so it seems that I got it wrong. Actually, after the loginpage_hook(), the user is redirected to the login page, which displays an error since the user is already identified. Which makes perfect sense (don't know why I didn't think about it).

I just added a "redirect($CFG->wwwroot);" under the call to "complete_user_login($user)", and it now works like a charm. smile

In reply to Brendan Abolivier

Re: You are already logged in as [...], you need to log out before logging in as different user.

by mark salga -

Brendan : I did it, adding under ""complete_user_login($user)"," but I still got the same answer

"You are already logged in as [...], you need to log out before logging in as different user."

What can I do?

any user that log in give me the same answer.


In reply to Brendan Abolivier

Re: You are already logged in as [...], you need to log out before logging in as different user.

by Roy Kommer -

In what file do i put the added Text:

redirect($CFG->wwwroot);

I've the samen problem.


Please help


Attachment site.png
In reply to Brendan Abolivier

Re: You are already logged in as [...], you need to log out before logging in as different user.

by Brijesh Yadav -

Where i put above code