简体   繁体   English

Zend Framework 2的原始PHP会话

[英]Original PHP Session with Zend Framework 2

Zend Framework 2 is not letting me use orginal PHP session. Zend Framework 2不允许我使用原始PHP会话。 I am using Responsive File Manager Application that is in public folder of zend framework 2. Whenever the dialog of file manager opens, I get following error. 我正在使用zend Framework 2公用文件夹中的响应文件管理器应用程序。每当打开文件管理器对话框时,都会出现以下错误。

Warning: Class __PHP_Incomplete_Class has no unserializer in E:\xampp\htdocs\MantissaAdmin\public\ResponsiveFilemanager\filemanager\config\config.php on line 2

Where on line 2, the code is 在第2行的代码是

session_start();

How can I make it so that Zend framework 2 do not interfere with the file manager session. 如何使Zend Framework 2不会干扰文件管理器会话。

This is not an issue of ZF2. 这不是ZF2的问题。 There is a serialized object in your session which php tries to unserialize when session_start is called. 您的会话中有一个序列化的对象,当调用session_start时,php试图将其反序列化。 But because PHP can't find the class (which is not declared), it uses __PHP_Incomplete_Class instead. 但是因为PHP找不到类(未声明),所以它改用__PHP_Incomplete_Class

See: PHP: unserialize - Manual 请参阅: PHP:反序列化-手册

The best way to fix: Register an autoloader to load missing classes. 修复的最佳方法:注册一个自动加载器以加载缺少的类。 You can dump the class name this way: 您可以通过以下方式转储类名称:

ini_set('unserialize_callback_func', '__unserialize_callback_func');
function __unserialize_callback_func($classname)
{
    var_dump($classname);
}
session_start();

In order to work with other 3rd party libraries and share sessions across software that may not be ZF2 related; 为了与其他第三方库一起工作,并在可能与ZF2不相关的软件之间共享会话; you will need to ensure that you still provide access to the ZF2 autoloader as well as module autoloading. 您将需要确保您仍然提供对ZF2自动加载器以及模块自动加载的访问权限。 In the shared software make certain before the session starts that you bootstrap the ZF2 autoloader and initialize the ZF2 Application. 在共享软件中,请确保在会话开始之前引导ZF2自动加载器并初始化ZF2应用程序。

$cwd = getcwd();
chdir('/path/to/zf2-application');
require 'init_autoloader.php';
Zend\Mvc\Application::init(require 'config/application.config.php');
chdir($cwd);
session_start();

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM