diff --git a/lib/weblib.php b/lib/weblib.php
index 60777e45650..6e0ca9fad9f 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -2480,8 +2480,8 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
}
define('HEADER_PRINTED', 'true');
-/// Perform some browser environment checks
- if (!empty($CFG->excludeoldflashclients) && empty($SESSION->flashversion)) { // Do a single check per session for the flash version
+/// Perform a browser environment check for the flash version. Should only run once per login session.
+ if (isloggedin() && !empty($CFG->excludeoldflashclients) && empty($SESSION->flashversion)) {
// Unfortunately we can't use require_js here and keep it all clean in 1.9 ...
// require_js(array('yui_yahoo', 'yui_event', 'yui_connection', $CFG->httpswwwroot."/lib/swfobject/swfobject.js"));
$meta .= '';
@@ -2491,9 +2491,8 @@ function print_header ($title='', $heading='', $navigation='', $focus='',
$meta .=
"";
-
}
diff --git a/login/environment.php b/login/environment.php
index 4d889660d1f..cdbd32b13b9 100644
--- a/login/environment.php
+++ b/login/environment.php
@@ -5,6 +5,8 @@
require('../config.php');
+require_sesskey();
+
if (!empty($SESSION)) {
if ($flashversion = optional_param('flashversion', false, PARAM_TEXT)) { // eg 10.0.32
$SESSION->flashversion = $flashversion;