]> git.mjollnir.org Git - moodle.git/commitdiff
Added cookie detection, based on Petr's code. Thanks!
authormoodler <moodler>
Tue, 11 Jan 2005 12:43:29 +0000 (12:43 +0000)
committermoodler <moodler>
Tue, 11 Jan 2005 12:43:29 +0000 (12:43 +0000)
A notice will be printed on the login page if the session cookie can not be set.

blocks/login/block_login.php
lang/en/moodle.php
login/index.php

index bdc02741e05a45898e6d1a38991df01faa35b19f..7fe7381fd693a22d18019002d52999509f8a54bf 100644 (file)
@@ -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  = "<form name=\"blocklogin\" method=\"post\"";
             $this->content->text .= " action=\"". $wwwroot ."/login/index.php\">\n";
index c8faa947cc85dae4db06f169981dae1a34fb9d9e..8cd0fe47060ec21b7a16a91c9e8dfe3e61651807 100644 (file)
@@ -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';
index dbe0519dcb24d0922984bcd5127a49244626a6d6..8c470dd32e991ce820883185ac1dc754f0136544 100644 (file)
         $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)) {
     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 = "";
     }