Moodle
  1. Moodle
  2. MDL-26480

The verification of the session functionality fails during the installation process

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.3
    • Component/s: Installation
    • Labels:
      None
    • Environment:
      Moodle 2.0.1+ (Build: 20110209)
      Windows 2003 server SP2
      MSSQL 2005, IIS 6
      PHP 5.3.5, php-cgi is used as a simple CGI (without FastCGI).
    • Database:
      Microsoft SQL
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank:
      16200

      Description

      The installation process fails before the admin profile initialization with the message "Can not initialise PHP session, please verify that your browser accepts cookies", in case when "php-cgi.exe" is mapped as handler in IIS directly, without FastCGI. The PHP sessions and cookies are functioning correctly.

      How to reproduce:
      1. To map php-cgi.exe as a handler for php extension in IIS;
      2. Delete config.php, database and start installation from the very beginning.

      The message appears when the moodle cannot set and after that read the variable "sessionverify" in "admin\index.php". This code uses the function "redirect()" from "weblib.php" which calls "header()" function in its turn. The problem disappears when we make the system save the session data before the "header()" function. As I know, it is recommended to use the function "session_write_close()" before using "header()" function to ensure that all session data has been saved.

      The following patch solves the problem in my case.

      from line 2456 in weblib.php:
      $encodedurl = preg_replace('/^.href="([^"])".*$/', "
      1", clean_text('<a href="'.$encodedurl.'" />'));
      if ($delay == 0 && !$debugdisableredirect && !headers_sent()) {
      //302 might not work for POST requests, 303 is ignored by obsolete clients.
      // start ----------------------------------------------
      if (isset($_SESSION['SESSION']))

      { session_get_instance()->write_close(); }

      // end ----------------------------------------------
      @header($_SERVER['SERVER_PROTOCOL'] . ' 303 See Other');
      @header('Location: '.$url);
      echo bootstrap_renderer::plain_redirect_message($encodedurl);
      exit;
      }

      // Include a redirect message, even with a HTTP redirect, because that is recommended practice.
      $PAGE->set_pagelayout('redirect'); // No header and footer needed
      $CFG->docroot = false; // to prevent the link to moodle docs from being displayed on redirect page.
      echo $OUTPUT->redirect_message($encodedurl, $message, $delay, $debugdisableredirect);
      exit;

      Regards,
      Zenger Sergey

        Activity

        Show
        Petr Škoda added a comment - More info here: http://bugs.php.net/bug.php?id=14636 and here http://support.microsoft.com/kb/q176113/
        Hide
        Petr Škoda added a comment -

        Thanks for the report and patch, the fix will be available in the next weekly build.

        Petr

        Show
        Petr Škoda added a comment - Thanks for the report and patch, the fix will be available in the next weekly build. Petr

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: