From: moodler Date: Tue, 11 Jan 2005 12:43:29 +0000 (+0000) Subject: Added cookie detection, based on Petr's code. Thanks! X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=792197b095ed19d8ff9ff20118b24585aed97978;p=moodle.git Added cookie detection, based on Petr's code. Thanks! A notice will be printed on the login page if the session cookie can not be set. --- diff --git a/blocks/login/block_login.php b/blocks/login/block_login.php index bdc02741e0..7fe7381fd6 100644 --- a/blocks/login/block_login.php +++ b/blocks/login/block_login.php @@ -43,7 +43,12 @@ class block_login extends block_base { $signup = ''; } - $username = get_moodle_cookie(); + if (get_moodle_cookie() == '') { + set_moodle_cookie('nobody'); // To help search for cookies + } + + $username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie(); + if (empty($USER->loggedin)) { $this->content->text = "
content->text .= " action=\"". $wwwroot ."/login/index.php\">\n"; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index c8faa947cc..8cd0fe4706 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -232,6 +232,7 @@ $string['confirmednot'] = 'Your registration has not yet been confirmed!'; $string['continue'] = 'Continue'; $string['continuetocourse'] = 'Click here to enter your course'; $string['cookiesenabled'] = 'Cookies must be enabled in your browser'; +$string['cookiesnotenabled'] = 'Unfortunately, cookies are currently not enabled in your browser'; $string['copy'] = 'copy'; $string['copyingcoursefiles'] = 'Copying course files'; $string['copyinguserfiles'] = 'Copying user files'; diff --git a/login/index.php b/login/index.php index dbe0519dcb..8c470dd32e 100644 --- a/login/index.php +++ b/login/index.php @@ -51,7 +51,17 @@ $frm = data_submitted(); } - if ($frm) { + if ($frm and (get_moodle_cookie() == '')) { // Login without cookie + + $errormsg = get_string("cookiesnotenabled"); + + } else if ($frm) { // Login WITH cookies + + if (get_moodle_cookie() == '') { + error('Cookies not working!'); + die; + } + $frm->username = trim(moodle_strtolower($frm->username)); if (($frm->username == 'guest') and empty($CFG->guestloginbutton)) { @@ -167,9 +177,13 @@ if (empty($SESSION->wantsurl)) { $SESSION->wantsurl = array_key_exists('HTTP_REFERER',$_SERVER) ? $_SERVER["HTTP_REFERER"] : $CFG->wwwroot; } + + if (get_moodle_cookie() == '') { + set_moodle_cookie('nobody'); // To help search for cookies + } if (empty($frm->username)) { - $frm->username = get_moodle_cookie(); + $frm->username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie(); $frm->password = ""; }