diff --git a/lib/moodlelib.php b/lib/moodlelib.php index f3af61186b1..2c2f49f7f31 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -3357,8 +3357,10 @@ function get_complete_user_data($field, $value, $mnethostid=null) { $user->lastname = ' '; } - $user->sesskey = random_string(10); - $user->sessionIP = md5(getremoteaddr()); // Store the current IP in the session + if (isset($_SERVER['REMOTE_ADDR'])) { + $user->sesskey = random_string(10); + $user->sessionIP = md5(getremoteaddr()); // Store the current IP in the session + } return $user; }