opencart:create_sid错误。我怎么卖?

时间:2016-10-20 10:07:09

标签: php session opencart2.x

我建立一个网站使用opencart,我最后一天有关于create_sid的错误。 网站工作完全localhost但不在ftp。

我努力工作的会话类,我看到它的本地会话类扩展了SessionHandler,本机类有这样的函数

会议开始像这样:

$session = new Session();
$session->start();

本地课程:

<?php
namespace Session;
class Native extends \SessionHandler {
public function create_sid() {
     return parent::create_sid();
}

当此行被执行时抛出并错误此

  

sessionHandler :: create_sid():无法在第0行调用Unknown中的默认会话处理程序

会话班:

 public function __construct($adaptor = 'native') {
    $class = 'Session\\' . $adaptor;

    if (class_exists($class)) {
        $this->adaptor = new $class($this);
    } else {
        throw new \Exception('Error: Could not load session adaptor ' . $adaptor . ' session!');
    }       

    if ($this->adaptor) {
        session_set_save_handler($this->adaptor);
    }

    if ($this->adaptor && !session_id()) {
        ini_set('session.use_only_cookies', 'Off');
        ini_set('session.use_cookies', 'On');
        ini_set('session.use_trans_sid', 'Off');
        ini_set('session.cookie_httponly', 'On');

        if (isset($_COOKIE[session_name()]) && !preg_match('/^[a-zA-Z0-9,\-]{22,52}$/', $_COOKIE[session_name()])) {
            exit('Error: Invalid session ID!');
        }

        session_set_cookie_params(0, '/');
        session_start();
    }           
}

public function start($key = 'default', $value = '') {
    if ($value) {
        $this->session_id = $value;
    } elseif (isset($_COOKIE[$key])) {
        $this->session_id = $_COOKIE[$key];
    } else {
        //error was created this line
        $this->session_id = $this->createId();
    }   

    if (!isset($_SESSION[$this->session_id])) {
        $_SESSION[$this->session_id] = array();
    }

    $this->data = &$_SESSION[$this->session_id];

    if ($key != 'PHPSESSID') {
        setcookie($key, $this->session_id, ini_get('session.cookie_lifetime'), ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure'), ini_get('session.cookie_httponly'));
    }

    return $this->session_id;
}

 public function createId() {
    if (version_compare(phpversion(), '5.5.4', '>') == true) {
        return $this->adaptor->create_sid();
    } elseif (function_exists('random_bytes')) {
        return substr(bin2hex(random_bytes(26)), 0, 26);
    } elseif (function_exists('openssl_random_pseudo_bytes')) {
        return substr(bin2hex(openssl_random_pseudo_bytes(26)), 0, 26);
    } else {
        return substr(bin2hex(mcrypt_create_iv(26, MCRYPT_DEV_URANDOM)), 0, 26);
    }
}

如果我删除$ session-&gt; start();线网站工作。

我该怎么卖?

0 个答案:

没有答案