-4

I am getting error for the line " /core/session/manager->start();"

Please advise for any solution for this error.

// Start session and prepare global $SESSION, $USER.
if (empty($CFG->sessiontimeout)) {
    $CFG->sessiontimeout = 7200;
}
 /core/session/manager->start();

// Set default content type and encoding, developers are still required to use
// echo $OUTPUT->header() everywhere, anything that gets set later should override these headers.
// This is intended to mitigate some security problems.
if (AJAX_SCRIPT) {
    if (!core_useragent->supports_json_contenttype()) {
        // Some bloody old IE.
        @header('Content-type: text/plain; charset=utf-8');
        @header('X-Content-Type-Options: nosniff');
    } else if (!empty($_FILES)) {
        // Some ajax code may have problems with json and file uploads.
        @header('Content-type: text/plain; charset=utf-8');
    } else {
        @header('Content-type: application/json; charset=utf-8');
    }
} else if (!CLI_SCRIPT) {
    @header('Content-type: text/html; charset=utf-8');
}
naresh
  • 1
  • 2
  • It's more than likely a missing semi-colon on the line before... although without more code it's difficult to tell. – Garry Welding Jun 17 '16 at 10:49
  • @GarryWelding please find the code before after the line mentioned in the question if (empty($CFG->sessiontimeout)) { $CFG->sessiontimeout = 7200; } /core/session/manager->start(); if (AJAX_SCRIPT) { if (!core_useragent->supports_json_contenttype()) { // Some bloody old IE. @header('Content-type: text/plain; charset=utf-8'); @header('X-Content-Type-Options: nosniff'); } – naresh Jun 17 '16 at 10:59
  • 1
    OK, I'm going to assume you're using namespaces which is why you're trying to do /core/session/manager->start(); however it should be \core\session\manager->start(); – Garry Welding Jun 17 '16 at 11:05
  • @GarryWelding, If I use "\core\session\manager->start();", I am getting the below errors. Warning: Unexpected character in input: '\' (ASCII=92) & Parse error: syntax error, unexpected T_STRING – naresh Jun 17 '16 at 11:08
  • What version of PHP are you using? – Garry Welding Jun 17 '16 at 12:12

2 Answers2

0

Namespace concept is compatible with PHP versions (PHP 5 >= 5.3.0, PHP 7). It may be a problem with PHP version. Please check your php version.

0

PHP namespaces syntax uses backslashes.

To fix the error, replace:

/core/session/manager->start();

With:

\core\session\manager->start();
Jocelyn
  • 11,209
  • 10
  • 43
  • 60