我是 zend 新手,我想问一下,如果用户闲置 10 分钟,如何才能使用户 session 命名空间的特定 key 过期。我在 zend session 中定义了一个命名空间
$session = new Zend_Session_Namespace('loginNamespace');
现在,当用户登录时,我在 session 命名空间中设置键loggedIn = 1。现在,如果用户保持空闲状态,我不想使整个 session 过期,而只想使该 key 过期。我该怎么做?
最佳答案
来自documentation ,您可以使用以下方法使 key 过期:
$session->setExpirationSeconds( 600, 'key' );
那么,你能怎么玩呢?这样:
// 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
}
关于php - 如果用户闲置 10 分钟,则使 Zend session 过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10975781/