OK I've tried pretty much everything I've seen in the posts here. Clearing cookies, using dbsessions, etc. There's got to be a better solution that will actually last a few minutes. Is Moodle 1.8 really that much of a mess. I ran 1.5 all last school year without a hitch. I thought "upgrading" to 1.8 would be just the ticket for more powerful user management. It's turning out to be a royal pain in the backside and my teachers are starting to look at me with cannibalistic glints in their eyes.
"A server error that affects your login session was detected. Please login again or restart your browser." is driving us crazy.
Developers, is there an answer? I've still got 1.5 up and running but would rather move on to the "better and more wonderful" version 1.8.
you Moodle shows this message because it detected a serious problem that affects the session handling in PHP. This is not a false alarm.
You should try fix your server or proxy if used, most probably there is nothing wrong with the code itself. You might try to update PHP and/or Apache.
The internal session test in 1.5 was similar but not exactly the same as in 1.8. We do not know for sure what caused the original "user switching" trouble, but the system upgrade helped in most cases.
My server is running PHP 5.2.2 and Apache version 1.3.37 (Unix). Shouldn't that be up to date enough? Perhaps I don't understand what you mean by updating them. I'm not using a proxy.
The site worked fine for about three days. I have been importing and creating courses. There seems to be a difference depending on which course I'm working with.
Is it possible that I have assigned conflicting roles or something that might cause this problem?
Your help is most appreciated.
I convinced my server host to switch machines for me twice in the last week to accommodate Moodle 1.8 already. I don't really have the option of switching machines just so I can try out a different version of PHP. It is very disappointing that Moodle isn't more universally compatible. It looks like my only real option is to go back to an earlier version.
It would have been nice to know 1.8 wasn't going to work before I spent 30 hours trying to get it to. The "environment" listing from within Moodle says my setup should be fine. It's very frustrating to find out it isn't with no better explanation than that I should try a different configuration.
The moodle download area says Moodle 1.8 is the best choice for a new server installation. I couldn't possibly disagree more.
try to change cookie prefix (Sessioncookie) from
Administration -> Server -> Session Handling (moodle 1.8)
Administration -> Configuration -> Variables (moodle 1.5)
It should solve your case if you have two moodles running at the same server with the same cookie prefix.
I am trying to install moodle 1.8.1 and I am stuck in the middle of the installation process with the same problem: "A server error..."
I am running another 1.5 moodle on the same server, so this may be the problem.
How can I manually change the default cookie prefix (Sessioncookie) for the moodle I am installing, before installing it?
Should this option made available in the setup?
Thank you in advance and best regards
I tried to modify the sessioncookie manually in the config.php by adding:
$CFG->sessioncookie = "whatever"
but to no avail.
The installation process goes smoothly till the last step where it points to the /admin directory.
Then I get a 404 error.
If I refresh the page I get the "A server error..." etc.
Any hint is much appreciated
sessioncookie should not prevent installing a new moodle - this sounds like some other problem. When you tried to install moodle 1.8 did you have different moodledata folder and different database (or prefix) and different config.php for both moodle versions? Do you have some .htaccess files?
EDIT: I just tested another possible reason: config.php
If you have some spaces AT THE BEGINNING of config.php you get this error too. A more common problem is to have empty rows at the end of config.php but anyway - check that too.
I have a different moodledata folder. I have also a different database, preloaded with the content of the previous 1.5 installation so that moodle can upgrade it.
I am on IIS so in general I do not make use of .htaccess
But I had the same problem also trying the same installation procedure in an easyphp 1.8 test environment (LAMP platform), both with a preloaded database and an empty database.
Did you check config.php ?
Talking about IIS - have you installed moodle 1.5 to use IIS too? Do your moodle 1.8 and 1.5 use the same port?
yes I checked config.php.
I am currently running 8 moodle websites on the same IIS server. I use IIS for production and easyphp for development.
Some of the moodles are in subfolders of the same base URL, such as:
and use the same port, but up to now I had no problem. Obviously they are using separate data dirs and separate databases.
The same on the development server.
Next thing I want to try is to install moodle 1.8.1 on a different URL (a third level such as test.foo.com), but I am still in the process of configuring this with my ISP.
I read somewhere that since moodle 1.7 the session code has been changed: maybe there is a new behaviour that I should take care of... separating all of the sites in different URLs.
Thank you again
Strange. I have had different versions of moodle 1.5-1.6-1.7-1.8 running in different subfolders of same URL and without any problems. It must be some other problem / change in moodle 1.8 or requirements of moodle 1.8 and your server environment are somehow incompatible. (????)
Did you try downloading moodle 1.8.1 again (if the file was corrupt during downloading) and a fresh install?
The new db is up and accessible.
that should be OK.
Moreover I upgraded mysql a week ago to the 4.1.21 version, with some extra pain to convert databases to utf8, just in order to get ready for this upgrade...
I do not believe the 1.8.1 zip file was corrupted: the admin/index.php file is in place.
I am able to run through all the install process untill it looks for the /admin directory: then I get 404 and if I refresh I get "A server error..."
The session file is created correctly in the data/session directory during the install process.
Anyway: I was able to install a couple of minutes ago, but only on an empty DB, no upgrade of existing db.
No changes from my side: just the usual procedure... should I believe in ghosts? ;)
As told before I added in config.php:
$CFG->sessioncookie = 'whatever';
In the footer of the homepage now I get a message:
"$CFG->sessioncookie in config.php (whatever) overrides database setting ()"
and the session cookie now has the correct form:
when I try to install moodle 1.8.1 on a not empty moodle DB in order to get it updated the install process does not set the right session cookie.
Moreover instead of giving the "A server error..." message, now I get always the 404 error just after the step that writes the config.php file and when trying to access the /admin directory.
I believe this does not depend on the database at all, but just on some quirk in the php session handling.
I tried both adding manually a line in config.php before clicking next:
$CFG->sessioncookie = 'whatelse';
and I tried changing the sessioncookie setting in the moodle_config table of the moodle database before clicking next in the installation page...
Will try again later! ;)
Someone with similar issue:
My first thought was (because fresh install works but upgraded version does not) that the problem is in your old moodledata/sessions folder and permissions there (read/write). Try to delete all old sessions from that folder or the whole sessions folder. Moodle should create a new sessions folder.
...and when you said you were updating database it came to my mind that straight upgrading from 1.5 to 1.8 usually does not succeed. It may succeed if database (collation and all tables) is converted correctly to unicode and you have only standard activities. It is safer to upgrade first to 1.6.(5+) with migration - 1.7.(2+) and then 1.8.(1+)
and remove non standard activities before upgrading. There have been a huge amount of changes from moodle 1.5 to 1.8 but if your new moodle 1.8 install is working OK the problem might just come from your upgrading process. My guess is that some old part of moodle 1.5 (missing/non upgraded activity/relic in database) could cause your problem. Upgrading is not finished if some essential part is missing or misconfigured...
I believe this is a problem in the session handling code. I have seen searching the forum for "A server error that affects your login session was detected. Please login again or restart your browser." that this lousy error is around maybe since 2005 and version 1.6, but it looks difficult to spot and reproduce.
I am looking into the various solutions that worked for somebody else, but up to now I found nothing working for me.
I will try changing more effectively the cookie name: it looks like the cookie remains the same even after adding:
$CFG->sessioncookie = "whatever"
in the config.php
Has anyone found a definitive answer to this problem? I've tried 3 fresh installs now, with 3 different versions, and still can't log on.
I log in and it takes me back to the default page saying I'm not logged on. Clicking login again shows the message "A server error that affects your login session was detected. Please login again or restart your browser."
There are sessions records in the database, and session files have been created in the folder structure. I've tried everything described in this discussion but still the same problem. Any more ideas please?
you could give some more information about your server. If you make a search with "a server error that affects your login session was detected" you should find many old answers too and every case is different. If you have not been able to log on even once I would guess there is something wrong with saving sessions (session save path may be incorrect/Windows server?, permissions/ownership for moodledata/sessions folder, some security feature on by default, firewall, wrong server time...)
Hi Mauno, thanks for the reply.
I've run the sessions test as described in that link:
"Session found - welcome back!
Sessions are working correctly"
I've installed Moodle on two seperate host servers now, with 2 seperate sql databases. Both fresh installs. I've tried to log on on a few different computers in a few different locations so don't think it's local machine. What information could I provide on the host servers which would help answer this question please?
attaching config.php might help and php info could give some tips too.
Some link to those sites/hosts, version of php and mysql, type of servers etc.
All such information is usefull.
We have two 1.9.3 Moodles on 1 server. We were getting this error (see attached pic.) until we change the cookie on 1 of the Moodle instances.
Administration -> Server -> Session -> Cookie prefix -> something
Thanks for the solution.
Thanks! I hadn't considered that. I don't think it's a problem they way I had it set up but, now that I know to look, I'll double check it. Your help and patience are truly appreciated.
This looks like great advice and was posted by Petr Skoda back in 2007.
I've been getting server errors for quite a while and my students and I are currently experiencing login problems.
My instance of Moodle seems to be accessible on both urls by default (I'm using Siteground).
- What's a safe or recommended way to make Moodle accessible from only one url?
Deletion en masse of one directory and it's contents seems drastic.
Is it better to change permissions and if so, what do I change them to?
Any input greatly appreciated.
We are also getting this error on two of our version 1.8.2 sites:
"A server error that affects your login session was detected. Please login again or restart your browser."
We have been using 1.6+ fine without any major bugs. Then we upgraded to 1.7 and then to 1.8.1 without any problems. Now that we have upgraded to 1.8.2 and this error is happening on every logout! The systems are on two different computers, locations and domains.
Deleting the cookies will eliminate this problem for a very short time, but the error returns.
It looks like this is surely a problem with the way session cookies are kept in 1.8.2. We have done everything mentioned in is this forum without any realsolution. This is becoming a great pain to solve and causing site users frustration.
Our 1.8.2 Environment:
Moodle Version 1.8.2
Name Information Report Status
unicode is required to be installed/enabled. OK
database mysql version 4.1.16 is required and you are running 4.1.20 OK
php version 4.3.0 is required and you are running 4.3.11 OK
php_extension iconv is recommended to be installed/enabled OK
php_extension mbstring is recommended to be installed/enabled OK
php_extension curl is recommended to be installed/enabled OK
php_extension openssl is recommended to be installed/enabled OK
php_extension tokenizer is recommended to be installed/enabled OK
2) Changing the cookie prefix under the Session Handling section doesn't help.
3) Changing the cookies path under the Session Handling section doesn't help.
4) No proxy is in use.
5) I've tried deleting the moodle/session folder and this doesn't stop the error.
6) The config.php file has been checked for blank spaces. No use!
Does anyone have any idea how to prevent this error from causing user discomfort? We need help badly! Our hairs are falling out because of this.
Is anyone looking into this issue? To have two site running in two different locations and domains with the exactly the same problem maybe the problem is related. We have tried changing the cookies again but the error is still around.
Any help on this?
"this error is happening on every logout"
- If you click three times quickly Logout you get always this error (one click is enough).
"Changing the cookie prefix under the Session Handling section doesn't help"
- Do you have different cookie prefix for these two moodles?
Have you tried database sessions from
Administration -> Server -> Session Handling -> Use database for session information
I had this same exact problem, but it only happened in IE for me. I am also running two different versions of moodle. I have both in subdirectories. I just made sure to change the cookie path to the directory that moodle is currently running in. I also changed the prefix of each cookie. Once I started putting the cookie into the same directory as where moodle is running, everything is working great.
I have no idea if I got lucky or what happened. Hopefully this helps.
I have the same problem. I am using Moodle 1.8 and it seems to work fine. The only time I get this error, "A server error that affects your login session was detected," is when I logout and then try to login.
How do I change the cookie path to my moodle directory? I know the default is "/", but do I use "/moodle" or www.name.org/moodle?
I figured out how to change the cookie path and it fixed my problem.
What I think was interesting that everything was working fine. I had been running two installs of Moodle no problem.
The "A server error that affects your login session was detected. Please login again or restart your browser." error appeared after I tried to login to the second of installation of Moodle in a tabbed browser window while the other was still running.
I also found that I could log in but when I tried to "Turn Editing on" the error would be displayed. Fortunately I could log in and choose the "Server" option and make the necessary changes.
I hope this helps others!
How did you "change the cookie path to the directory that moodle is currently running in and also change the prefix of each cookie"? Would you give me an example? What did you change? Do I need to change something other than the 'cookie prefix'?
I keep receiving the error A server error that affects your login session was detected. Please login again or restart your browser. I am running multiple moodles on a single server. I wanted to keep finals and different states and course files in separate moodles. The moodles are running from different folders with unique folder names within a single domain name at a single host www.domainname.com/moodle www.domainname.com/courses . I am running 1.9. It is starting to happen even when I first open a new browser.
I don't know if the moodledata folder matters, but I am running 1 moodledata folder with separate numbered folder for each moodle.
I read all of the documentation. I don't know where to start and these are existing moodles and seem to work fine except for these errors. I don't want to loose control of them.
I'm not sure if you're still in need of an answer - or for others still in need...
I would set the cookie prefix different for each of the moodle sites and then make sure all the moodledata folders have 777 permissions, also double check your config.php files to make sure that each moodle is pointing to a different database.
I hope this helps
Maybe I misunderstood you, but isn't having 777 permissions on all moodledata folders risky?
In my setup I've tried my best to restrict permissions as much as possible, and it seems that in yours all users have read/write/execute permissions on the moodledata folder...
I'm sorry if I misunderstood you!
If you are using shared hosting 777 may be the only permissions that you can use to get everything working; it is a different story if you are using a dedicated server. As long as the moodledata folder is not directly web accessible then most of the security issues are nothing to worry about.
For a far more detailed statement of security and file permissions, I recommend having a read of this page in the docs: Security#Most_secure.2Fparanoid_file_permissions
Thanks for your reply, I have no experience setting moodle up in a shared hosting environment, so it was educational
But there was a little difference which I realized after some tests: on that server, Apache was running as a different Linux user than Apache-ssl, so the session created for logging in with HTTPS was not readable for HTTP server (and vice-versa).
So, when you use HTTPS to log in you should run your both www servers (HTTP and HTTPS) as the same user... It is usually a default option (my different users was my own change, needed some times ago).
Maybe it helps someone...
Error: Database connection failed.
It is possible that the database is overloaded or otherwise not running properly.
The site administrator should also check that the database details have been correctly specified in config.php
I had a teacher that was receiving this message. She was also unable to edit any quiz questions that had images (and the image links were broken). While researching, I found this thread and noticed that her image links were broken because they were referring to the incorrect moodle installation.
I am running Moodle 1.9.8+. I have two installs on a single IIS server.
Both are running on their own database and their own data folders. The data folders are outside the htdocs and the permissions are 0777.
Her quiz was in moodle2020 but were trying to pull images from moodle. I tried to change her cookie path to /moodle2020. This has fixed all errors in moodle2020 and everyone is able to login without errors. She was able to edit and add pictures to questions.
Now, however, I cannot login to the original moodle AT ALL! I do not receive any errors. Upon login, it just goes back to the home page and asks me to login again. This installation of moodle was working properly before I changed the cookie path in the moodle2020 installation.
Any suggestions on how to get both installations up and running properly?