Fixed $USER and $SESSION to be pointers to the real $_SESSION

variables, so there's no longer a need for save_session  (thanks,Petri)
This commit is contained in:
moodler 2003-02-27 02:38:55 +00:00
parent 4e94d2608b
commit 08c17336a7
3 changed files with 9 additions and 20 deletions

View 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;

View File

@ -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) ) {

View 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";
}