Moodle Tip- Session Cookies


Image Source: Managing Moodle

Problem: moodle server error on login…I have to keep logging in every few seconds and my Moodles (on one server) seem to fight each other.

On a Moodle server I manage, I had several moodle installations that I wanted to “move” or change. They included the following:

  1. ICan – This is a professional learning moodle for delivering courses. It had been setup by a highly esteemed colleague but there were some problems. The first was that the database name didn’t match the Moodle directory name, and neither did the Moodledata directory.
  2. CTRCenter – This is a campus technology center Moodle that had been invaded by zillions of student users who were engaged in online literature circles, etc. There were thousands of accounts and I felt that this Moodle had TOO many courses running down the front page…simply, this was the original Moodle installation and it was just weighed down. I decided to offload professional learning courses, create a new Moodle to handle the CTR specific stuff, and leave this as the “Open Campus”–a name one of my team thought up–for students.

In short, the new Moodle layout would look like this:

  • Professional Learning Center (PLC) – this is the new name of the iCan Moodle. I simply copied all the files in the iCan directory to the new directory, copied the contents of the iCan database from “ican_moodle” to “plc_moodle”, renamed the datadirectory from “icanmoodledata” to “plc_moodledata” and, finally, updated the configuration file to reflect my changes. This left me with the original “iCan” directories and databases for backup in case anything went wrong.
  • iTech – This is the name of the newly created Moodle that replaces the old CTRCenter. I pretty much worked the same way as the PLC, although it did involve backing up courses from here and restoring them to PLC Moodle.
  • CTRCenter – This site basically involved clean up of irrelevant courses. I’ll rename the directory and the databases (what I went through with PLC Moodle) this summer when I don’t have to worry about bookmarks staying the same.

One thing that bugged me, though. Logins were extremely short. It was like all the Moodles were competing with one another for login rights. I knew this problem was influenced by cookies but I had no idea what to do.

To fix that, I did a search with these keywords:

moodle server error on login

And ran across this tip in the Moodle forums regarding session cookies from Gustav W. Delius:

if you are getting such session problems when you are logged into two moodle installations on the same server then you should change the setting for “sessioncookie” in your site configuration variables so that they are different for the two installations.

As a result of this advice, I went into Admin mode, clicked on SERVER:SESSION HANDLING (this is on Moodle 1.9.4+) and modified the session cookie…it looks like this:

This allows me to be logged in on multiple Moodle sites without them fighting each other over the session cookie. It virtually eliminates the errors about “Error with your login” and then having to log back in again.

Finally, check out the Moodle Tip Roundup, Moodle Habitudes, and Moodle Mambo!


var addthis_pub=”mguhlin”;


Subscribe to Around the Corner-MGuhlin.org


Be sure to visit the ShareMore! Wiki.


Everything posted on Miguel Guhlin’s blogs/wikis are his personal opinion and do not necessarily represent the views of his employer(s) or its clients. Read Full Disclosure


Discover more from Another Think Coming

Subscribe to get the latest posts sent to your email.

Leave a comment