Internet Explorer bug that allows sends cookies to different sites if
they have the same ending. eg moodle.com cookie is sent to smec.moodle.com!!
Also fixes case where multiple moodle installations may be in different
directories on the same server. When you go from one to the other the
first session will be destroyed now (you can't be logged in the two
at the same time). It's just a lot safer this way, for now.
Basically this works by storing the wwwroot variable in the session
and checking it for every page.
// First check that the user is logged in to the site.
- if (! (isset($USER->loggedin) and $USER->confirmed) ) { // They're not
+ if (! (isset($USER->loggedin) and $USER->confirmed and ($USER->site == $CFG->wwwroot)) ) { // They're not
$SESSION->wantsurl = $FULLME;
$SESSION->fromurl = $HTTP_REFERER;
save_session("SESSION");
+ $USER = NULL;
+ save_session("USER");
if ($PHPSESSID) { // Cookies not enabled.
redirect("$CFG->wwwroot/login/?PHPSESSID=$PHPSESSID");
} else {
print_footer();
die;
}
-
+
$USER = $user;
$USER->loggedin = true;
+ $USER->site = $CFG->wwwroot; // for added security
save_session("USER");
if (!update_user_in_db()) {