如果用户空闲 10 分钟,则使 Zend 会话过期 [英] Expire the Zend session if the user remains idle for 10 minutes
本文介绍了如果用户空闲 10 分钟,则使 Zend 会话过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 Zend 的新手,我想问一下,如果用户空闲 10 分钟,我如何使用户会话命名空间的特定密钥过期.我在 zend 会话中定义了一个命名空间
I am new to zend and I want to ask how can I expire a user's session namespace's particular key if a user remains idle for 10 minutes. I have a namespace defined in zend session as
$session = new Zend_Session_Namespace('loginNamespace');
现在,当用户登录时,我在会话命名空间中设置了登录键 = 1.现在,如果用户保持空闲,而只是该密钥,我不想使整个会话过期.我该怎么做?
now when the user logs in I set the key loggedIn = 1 in session namespace. Now I want to expire not the whole session if the user remains idle but only that key. how can I do that?
推荐答案
来自 文档,您可以使用以下方法使密钥过期:
From the documentation, you can expire a key using:
$session->setExpirationSeconds( 600, 'key' );
那么,你怎么玩呢?这样:
So, how can you play with that? This way:
// Set "dummy" key with expiration
$session->setExpirationSeconds( 600, 'key' );
// Then, you can check if this key exists
if ( $session->key ) {
// Just reset the expiration
$session->setExpirationSeconds( 600, 'key' );
}
else {
// Delete your other key
}
这篇关于如果用户空闲 10 分钟,则使 Zend 会话过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文