简体   繁体   English

找不到SessionHandlerInterface

[英]SessionHandlerInterface not found

I have this error: 我有这个错误:

Interface 'SessionHandlerInterface' not found in /membri/francescorizzi/php_SessionMgr/MySessionHandler.php on line 3 在第3行的/membri/francescorizzi/php_SessionMgr/MySessionHandler.php中找不到接口“ SessionHandlerInterface”

here is my interface code (taken from php.net as a start point): 这是我的界面代码(取自php.net作为起点):

<?php
class MySessionHandler implements SessionHandlerInterface{

private $savePath;

public function open($savePath, $sessionName)
{
    $this->savePath = $savePath;
    if (!is_dir($this->savePath)) {
        mkdir($this->savePath, 0777);
    }

    return true;
}

public function close()
{
    return true;
}

public function read($id)
{
    return (string)@file_get_contents("$this->savePath/sess_$id");
}

public function write($id, $data)
{
    return file_put_contents("$this->savePath/sess_$id", $data) === false ? false : true;
}

public function destroy($id)
{
    $file = "$this->savePath/sess_$id";
    if (file_exists($file)) {
        unlink($file);
    }

    return true;
}

public function gc($maxlifetime)
{
    foreach (glob("$this->savePath/sess_*") as $file) {
        if (filemtime($file) + $maxlifetime < time() && file_exists($file)) {
            unlink($file);
        }
    }

    return true;
}
}

I tried also using implements \\SessionHandlerInterface or use SessionHandlerInterface but this didn't work. 我也尝试使用implements \\SessionHandlerInterfaceuse SessionHandlerInterface但这没有用。

How to solve this? 如何解决呢?

Thanks! 谢谢!

EDIT: 编辑:

I noticed that if i load all my code throught URL: 我注意到如果我通过URL加载所有代码:

www.site.org/main.php?... www.site.org/main.php?...

it works, but if i use this: 它有效,但是如果我用这个:

www.site.org/index.html?... www.site.org/index.html?...

the error comes up. 错误出现。

My index.html page includes the main.php code. 我的index.html页面包含main.php代码。 Where is the error? 错误在哪里?

INDEX.HTML CODE: INDEX.HTML代码:

<html>
<body bgcolor="#000000">
<body text="grey">
<?php include('Main.php') ?>
</body>
</html>

.htaccess file: .htaccess文件:

# # av:php5-engine
AddHandler av-php56 .php
AddType application/x-httpd-php .htm .html
RewriteRule ^index.html$ main.php

Is it possible that you are using an older PHP version? 您是否可能使用的是较旧的PHP版本? As stated in the official PHP documentation, the SessionHandlerInterface is only available starting with PHP 5.4.0 如官方PHP文档所述,SessionHandlerInterface仅从PHP 5.4.0开始可用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在第 8 行的 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/CacheBasedSessionHandler.php 中找不到接口“SessionHandlerInterface” - Interface 'SessionHandlerInterface' not found in /var/www/html/vendor/laravel/framework/src/Illuminate/Session/CacheBasedSessionHandler.php on line 8 使用SessionHandlerInterface的PHP错误命名空间 - PHP error namespace with SessionHandlerInterface PHP致命错误SessionHandlerInterface - PHP Fatal Error SessionHandlerInterface SessionHandlerInterface写方法的替代方法 - SessionHandlerInterface write method alternatives SessionHandlerInterface写入方法未被调用 - SessionHandlerInterface write method not being called spl_autoload_register,SessionHandlerInterface和PHPUnit的问题 - Problems with spl_autoload_register, SessionHandlerInterface and PHPUnit 在自定义SessionHandlerInterface实现中确保会话严格模式 - Ensuring session strict mode in custom SessionHandlerInterface implementation SessionHandlerInterface::write 和 SessionUpdateTimestampHandlerInterface::updateTimestamp 有什么区别? - What is the difference between SessionHandlerInterface::write and SessionUpdateTimestampHandlerInterface::updateTimestamp? 警告:session_set_save_handler()期望参数1为SessionHandlerInterface,给定对象 - Warning: session_set_save_handler() expects parameter 1 to be SessionHandlerInterface, object given Symfony 2 - 致命错误:无法在第532行的C:\\ ... \\ app \\ cache \\ dev \\ classes.php中重新声明类SessionHandlerInterface - Symfony 2 - Fatal error: Cannot redeclare class SessionHandlerInterface in C:\…\app\cache\dev\classes.php on line 532
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM