session.upload_progress自动启动会话

时间:2016-01-25 15:44:43

标签: php session zend-framework zend-session

PHP session.upload_progress是一个很好的库来跟踪你的上传进度,但是当你把文件发送到服务器时,session.upload_progress会自动启动php会话,但是当你调用时,Zend Framework不能正常运行导致异常: / p>

$Session = new Zend_Session_Namespace ( 'zend_session' , true );

例外:

session has already been started by session.auto-start or session_start()

将session.auto_start设置为“Off”, 我在页面顶部放置了以下代码:

// no one command is executed before this
echo "<pre>";
print_r ($_SESSION );
exit;
  • 只是在没有上传的情况下调用页面:PHP说没有设置$ _SESSION
  • 使用文件发布表单:PHP显示整个$ _SESSION var,即使不调用session_start()

我的会话部分配置:

Session Support     enabled
Registered save handlers    files user memcache memcached redis
Registered serializer handlers  php_serialize php php_binary wddx igbinary

Directive   Local Value Master Value
session.auto_start      Off Off
session.cache_expire    180 180
session.cache_limiter   nocache nocache
session.cookie_domain   no value    no value
session.cookie_httponly Off Off
session.cookie_lifetime 0   0
session.cookie_path     /   /
session.cookie_secure   Off Off
session.entropy_file    /dev/urandom    /dev/urandom
session.entropy_length  32  32
session.gc_divisor      1000    1000
session.gc_maxlifetime  1440    1440
session.gc_probability  1   1
session.hash_bits_per_character 5   5
session.hash_function   0   0
session.name    PHPSESSID   PHPSESSID
session.referer_check   no value    no value
session.save_handler    files   files
session.save_path       /tmp    /tmp
session.serialize_handler   php php
session.upload_progress.cleanup Off Off
session.upload_progress.enabled On  On
session.upload_progress.freq    1%  1%
session.upload_progress.min_freq    1   1
session.upload_progress.name    PHP_SESSION_UPLOAD_PROGRESS PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix  upload_progress_    upload_progress_
session.use_cookies         On  On
session.use_only_cookies    On  On
session.use_strict_mode     Off Off
session.use_trans_sid       1   1

我的代码中没有session_start(),我只是让ZendFramework运行:

Zend_Registry::set( "session" , new Zend_Session_Namespace ( 'zend_session' , true ) ) ;

1 个答案:

答案 0 :(得分:0)

在Zend_Session()中:456测试:

if (!self::$_unitTestEnabled && defined('SID')) ...

已定义SID,但$ _SESSION为空。但是问题在于这是一个Zend Framework类,您可以根据需要对其进行注释,但是建议不要更改框架文件