无法在Zend_Application中使用Zend_Auth和Zend_Session_SaveHandler_DbTable

时间:2010-09-18 05:33:51

标签: php zend-framework

我使用Zend_Session_SaveHandler_DbTable将我的会话存储在数据库中。我的application.ini

中有以下内容
resources.session.save_path = APPLICATION_PATH "/../data/sessions"
resources.session.use_only_cookies = true
resources.session.remember_me_seconds = 864000
resources.session.saveHandler.class = "Zend_Session_SaveHandler_DbTable"
resources.session.saveHandler.options.name = "session"
resources.session.saveHandler.options.primary.session_id = "session_id"
resources.session.saveHandler.options.primary.save_path = "save_path"
resources.session.saveHandler.options.primary.name = "name"
resources.session.saveHandler.options.primaryAssignment.session_id = "sessionId"
resources.session.saveHandler.options.primaryAssignment.save_path = "sessionSavePath"
resources.session.saveHandler.options.primaryAssignment.name = "sessionName"
resources.session.saveHandler.options.modifiedColumn = "modified"
resources.session.saveHandler.options.dataColumn = "session_data"
resources.session.saveHandler.options.lifetimeColumn = "lifetime"
resources.session.saveHandler.options.userIdColumn = "user_id"

会话似乎在数据库中正确保存。

问题是当我在应用程序中调用Zend_Auth :: getInstance() - > hasIdentity()时,它最终将调用Zend_Session :: start(true),这将导致错误:

  

致命错误:C:\ Program Files(x86)\ Zend \ Apache2 \ htdocs \ myapp \ library \中的session.auto-start或session_start()已启动带有消息'session的未捕获异常'Zend_Session_Exception' Zend \ Session.php:462堆栈跟踪:#0 C:\ Program Files(x86)\ Zend \ Apache2 \ htdocs \ myapp \ library \ Zend \ Session \ Namespace.php(143):Zend_Session :: start(true)# 1 C:\ Program Files(x86)\ Zend \ Apache2 \ htdocs \ myapp \ library \ Zend \ Auth \ Storage \ Session.php(87):Zend_Session_Namespace-> __ construct('Zend_Auth')#2 C:\ Program Files (x86)\ Zend \ Apache2 \ htdocs \ myapp \ library \ Zend \ Auth.php(91):Zend_Auth_Storage_Session-> __ construct()#3 C:\ Program Files(x86)\ Zend \ Apache2 \ htdocs \ myapp \ library \ Zend \ Auth.php(141):Zend_Auth-> getStorage()#4 C:\ Program Files(x86)\ Zend \ Apache2 \ htdocs \ myapp \ application \ modules \ default \ views \ scripts \ layout.phtml( 29):Zend_Auth-> hasIdentity()#5 C:\ Program Files(x86)\ Zend \ Apache2 \ htdocs \ myapp \ library \ Zend \ View.php(108):include('C:\ Prog in C: \ Program Files(x86 )\ Zend \ Apache2 \ htdocs \ myapp \ library \ Zend \ Session.php第462行

因为Zend_Session_SaveHandler_DbTable已经启动了会话。我虽然Zend_Session_SaveHandler_DbTable会自动让Zend_Auth将会话信息存储在数据库中。

我在这里缺少什么或者配置不正确吗?

1 个答案:

答案 0 :(得分:0)

文档(http://framework.zend.com/manual/en/zend.application.available-resources.html#zend.application.available-resources.session)在application.ini

中设置保存处理程序不正确

它应该是:

  

resources.session.save_path =   APPLICATION_PATH“/../data/sessions”   resources.session.use_only_cookies =   真正   resources.session.remember_me_seconds   = 864000 resources.session.saveHandler.class =   “Zend_Session_SaveHandler_DbTable”   resources.session.saveHandler.options.name   =“session”resources.session.saveHandler.options.primary []   =“session_id”resources.session.saveHandler.options.primary []   =“save_path”resources.session.saveHandler.options.primary []   =“name”resources.session.saveHandler.options.primaryAssignment []   =“sessionId”resources.session.saveHandler.options.primaryAssignment []   =“sessionSavePath”resources.session.saveHandler.options.primaryAssignment []   =“sessionName”resources.session.saveHandler.options.modifiedColumn   =“modified”resources.session.saveHandler.options.dataColumn   =“session_data”resources.session.saveHandler.options.lifetimeColumn   =“终身”

我已提交ZF问题:http://framework.zend.com/issues/browse/ZF-10471