]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed $USER and $SESSION to be pointers to the real $_SESSION
authormoodler <moodler>
Thu, 27 Feb 2003 02:38:55 +0000 (02:38 +0000)
committermoodler <moodler>
Thu, 27 Feb 2003 02:38:55 +0000 (02:38 +0000)
variables, so there's no longer a need for save_session  (thanks,Petri)

lib/moodlelib.php
lib/setup.php
lib/weblib.php

index befe23378f804769b803bcbb2a5d025037b79e76..f34b78f4a1ab21a260b286a235d769da112014b4 100644 (file)
@@ -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;
index 9a1f7da4e37dd6c59da15dc5689d75c1b0540e68..6f378fc2ff4e3e1acdc358e8de4df2cd962b6cd7 100644 (file)
     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;
 
     if (isset($lang)) {
         $SESSION->lang = $lang;
-        save_session("SESSION");
     }
 
     if (!empty($SESSION->lang) and ($SESSION->lang != $CFG->lang) ) {
index 80352f03bc8e1a29a78266681308e951576638fa..55b7021befe26ea0519bcd0dc1170b3fc57653cb 100644 (file)
@@ -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";
         }