From: moodler Date: Thu, 27 Feb 2003 02:38:55 +0000 (+0000) Subject: Fixed $USER and $SESSION to be pointers to the real $_SESSION X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=08c17336a78449cbb63daafe5296acd06cb81c43;p=moodle.git Fixed $USER and $SESSION to be pointers to the real $_SESSION variables, so there's no longer a need for save_session (thanks,Petri) --- diff --git a/lib/moodlelib.php b/lib/moodlelib.php index befe23378f..f34b78f4a1 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -271,9 +271,7 @@ function require_login($courseid=0) { if (!empty($_SERVER["HTTP_REFERER"])) { $SESSION->fromurl = $_SERVER["HTTP_REFERER"]; } - save_session("SESSION"); $USER = NULL; - save_session("USER"); if ($PHPSESSID) { // Cookies not enabled. redirect("$CFG->wwwroot/login/index.php?PHPSESSID=$PHPSESSID"); } else { @@ -322,7 +320,6 @@ function require_login($courseid=0) { // Currently not enrolled in the course, so see if they want to enrol $SESSION->wantsurl = $FULLME; - save_session("SESSION"); redirect("$CFG->wwwroot/course/enrol.php?id=$courseid"); die; } @@ -333,7 +330,6 @@ function update_user_login_times() { $USER->lastlogin = $user->lastlogin = $USER->currentlogin; $USER->currentlogin = $user->currentlogin = time(); - save_session("USER"); $user->id = $USER->id; @@ -356,11 +352,9 @@ function update_login_count() { } else { $SESSION->logincount++; } - save_session("SESSION"); if ($SESSION->logincount > $max_logins) { unset($SESSION->wantsurl); - save_session("SESSION"); error(get_string("errortoomanylogins")); } } @@ -370,7 +364,6 @@ function reset_login_count() { global $SESSION; $SESSION->logincount = 0; - save_session("SESSION"); } @@ -487,14 +480,6 @@ function get_moodle_cookie() { } -function save_session($VAR) { -/// Copies temporary session variable to permanent session variable -/// eg $_SESSION["USER"] = $USER; - global $$VAR; - $_SESSION[$VAR] = $$VAR; -} - - function create_user_record($username, $password) { /// Creates a bare-bones user record global $REMOTE_ADDR, $CFG; diff --git a/lib/setup.php b/lib/setup.php index 9a1f7da4e3..6f378fc2ff 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -134,9 +134,15 @@ class object {}; @session_start(); - if (! isset($_SESSION["SESSION"])) { $_SESSION["SESSION"] = new object; } - if (! isset($_SESSION["USER"])) { $_SESSION["USER"] = new object; } - extract($_SESSION); // Makes $SESSION and $USER available for read-only access + if (! isset($_SESSION['SESSION'])) { + $_SESSION['SESSION'] = new object; + } + if (! isset($_SESSION['USER'])) { + $_SESSION['USER'] = new object; + } + + $SESSION = &$_SESSION['SESSION']; // Makes them easier to reference + $USER = &$_SESSION['USER']; if (isset($FULLME)) { $ME = $FULLME; @@ -159,7 +165,6 @@ if (isset($lang)) { $SESSION->lang = $lang; - save_session("SESSION"); } if (!empty($SESSION->lang) and ($SESSION->lang != $CFG->lang) ) { diff --git a/lib/weblib.php b/lib/weblib.php index 80352f03bc..55b7021bef 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -1071,7 +1071,6 @@ function error ($message, $link="") { if ( !empty($SESSION->fromurl) ) { $link = "$SESSION->fromurl"; unset($SESSION->fromurl); - save_session("SESSION"); } else { $link = "$CFG->wwwroot"; }