Zend Auth锁定的会话 [英] Zend Auth locked session

查看:85
本文介绍了Zend Auth锁定的会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我几乎对Zend的处理方式感到沮丧.

i nearly frustrated with how Zend handling session.

这是我的情况.我编写了一个auth插件,该插件始终检查用户凭据是否使用Zend_Auth.从zend auth调用hasIdentity函数时,它将自动启动会话.

here is my case. i write a auth plugin that always check the the user credential utilize Zend_Auth. and when invoke hasIdentity function from zend auth, it will automatically start the session.

当我需要执行很长的过程时,问题就来了.会话将锁定请求,直到请求完成.我尝试通过调用Zend_Session :: writeClose(false)释放锁,因此可以执行另一个请求. 但我没有办法重新开始会议.

and the problem come when i have a long process that i need to execute. the session will lock the request until request completed. i try to release the lock by invoke Zend_Session::writeClose(false), so another request can be executed. but no way for me to start the session again.

如果我尝试恢复已停止的会话,是否执行不正确?

is it a bad implementation if i try to resume stoped session?

从开始到请求执行结束只有一个会话?

there is only one session from the start until request execution ended?

谢谢.

ps:我可以在这里做一点修改.在auth插件的末尾,我编写了一个本机php函数(session_write_close),如果有任何控制器需要再次使用会话,则可以使用(session_start)重新启动它.

ps : i can do a little hack here. at the end of auth plugin i write a native php function (session_write_close) and if any controller need to use session again, i start it again with (session_start).

推荐答案

最简单的解决方案是使用数据库进行会话存储.无需担心文件锁定(如ArneRie所述).

The easiest solution to this problem is to use a database for session storage. No file locks to worry about (as ArneRie mentined).

使用通用的PHP扩展名和对php.ini的细微调整:

Use a common PHP extension and a tiny tweak to php.ini:

您可以将它们存储在NFS导出中,或使用例如SQL后端重新编码session_set_save_handler.但是,没有比使用memcached更有效,更可扩展,更高性能,更易于部署的解决方案了……

You can store them on a NFS export or recode the session_set_save_handler using a SQL backend for example. But there is no solution more efficient, more scalable, more performant and easier to deploy than using memcached…

教程: http://www.dotdeb.org/2008/08/25/storing-your-php-sessions-using-memcached/

Zend方式,通过Zend_Session_SaveHandler_DbTable.

The Zend way, through Zend_Session_SaveHandler_DbTable.

示例: Zend-在数据库中存储会话数据

这篇关于Zend Auth锁定的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆