$SESSION->fromurl = $_SERVER["HTTP_REFERER"];
}
$USER = NULL;
- $loginguest = (isset($CFG->loginguests) and $CFG->autologinguests
- and $courseid and get_field('course','guest','id',$courseid)) ? '?loginguest=true' : '';
+ if (!empty($CFG->autologinguests)) {
+ $loginguest = ($courseid and get_field('course','guest','id',$courseid)) ? '?loginguest=true' : '';
+ }
if (empty($CFG->loginhttps)) {
redirect("$CFG->wwwroot/login/index.php$loginguest");
} else {