Skip to content

Commit

Permalink
MDL-11927 fixed cookiepaths; patch by Kevin
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Oct 28, 2007
1 parent d121490 commit 1504e26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/moodlelib.php
Expand Up @@ -2552,8 +2552,8 @@ function set_moodle_cookie($thing) {
$days = 60;
$seconds = DAYSECS*$days;

setCookie($cookiename, '', time() - HOURSECS, '/');
setCookie($cookiename, rc4encrypt($thing), time()+$seconds, '/');
setCookie($cookiename, '', time() - HOURSECS, $CFG->sessioncookiepath);
setCookie($cookiename, rc4encrypt($thing), time()+$seconds, $CFG->sessioncookiepath);
}

/**
Expand Down
8 changes: 6 additions & 2 deletions lib/setup.php
Expand Up @@ -382,10 +382,13 @@
require_once($CFG->libdir. '/adodb/session/adodb-session2.php');
}
}
/// Set sessioncookie variable if it isn't already
/// Set sessioncookie and sessioncookiepath variable if it isn't already
if (!isset($CFG->sessioncookie)) {
$CFG->sessioncookie = '';
}
if (!isset($CFG->sessioncookiepath)) {
$CFG->sessioncookiepath = '/';
}

/// Configure ampersands in URLs

Expand Down Expand Up @@ -495,14 +498,15 @@ class object {};

if (empty($nomoodlecookie)) {
session_name('MoodleSession'.$CFG->sessioncookie);
session_set_cookie_params(0, $CFG->sessioncookiepath);
@session_start();
if (! isset($_SESSION['SESSION'])) {
$_SESSION['SESSION'] = new object;
$_SESSION['SESSION']->session_test = random_string(10);
if (!empty($_COOKIE['MoodleSessionTest'.$CFG->sessioncookie])) {
$_SESSION['SESSION']->has_timed_out = true;
}
setcookie('MoodleSessionTest'.$CFG->sessioncookie, $_SESSION['SESSION']->session_test, 0, '/');
setcookie('MoodleSessionTest'.$CFG->sessioncookie, $_SESSION['SESSION']->session_test, 0, $CFG->sessioncookiepath);
$_COOKIE['MoodleSessionTest'.$CFG->sessioncookie] = $_SESSION['SESSION']->session_test;
}
if (! isset($_SESSION['USER'])) {
Expand Down

0 comments on commit 1504e26

Please sign in to comment.