From 9b1e8d728a4189f8a3e6f3a347ddd7d9d60e61b9 Mon Sep 17 00:00:00 2001 From: defacer Date: Mon, 13 Jun 2005 02:50:46 +0000 Subject: [PATCH] Adding a little more checking to the session switching trap code. I 've come across a problem where: 1. You have an "old" (say 1.3.5?) Moodle installation. 2. You are logged in as admin. 3. You suddenly switch to using a 1.5+ codebase with the SAME database, WITHOUT LOGGING OUT FIRST. In this situation, I was presented with a deadlock. I could not do anything because "my session had expired", and I could not even log OUT to clear my session. In fact it was just reloading the "session expired page" all the time. If it weren't for debug = On which causes a notice in these circumstances, it would be fracking difficult to understand what was going on. With this small addition, you can at least visit your login page and log in anew, so problem fixed. I believe this was talked about in the forums lately? Not sure. --- lib/setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/setup.php b/lib/setup.php index 81136a80c1a..2e746ee1af9 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -339,7 +339,7 @@ global $THEME; if ($SESSION != NULL) { if (empty($_COOKIE['MoodleSessionTest'.$CFG->sessioncookie])) { report_session_error(); - } else if ($_COOKIE['MoodleSessionTest'.$CFG->sessioncookie] != $SESSION->session_test) { + } else if (isset($SESSION->session_test) && $_COOKIE['MoodleSessionTest'.$CFG->sessioncookie] != $SESSION->session_test) { report_session_error(); } }