问题
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');
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?
回答1:
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
}
来源:https://stackoverflow.com/questions/10975781/expire-the-zend-session-if-the-user-remains-idle-for-10-minutes