简体   繁体   中英

How to get starting time of session in CakePHP?

I need to know when current session started.
I can store that value like this:

$this->Session->write('sessionStartTime', time());

But at what point should I add this code to CakePHP 2.4.6 ?
Should I add to AppController's beforeFilter() or is there a better place to put it ?
Or does CakePHP gives session start time ?

Edit:
Also there is a low level solution like this.
But I don't prefer because it depends to the session store type.

$timestamp = filemtime( TMP.'sessions'.DS.'sess_'.session_id() );

Session.timeout - The number of minutes before CakePHP's session handler expires the session. This affects Session.autoRegenerate (below), and is handled by CakeSession. please visit the official documentation

and cookies

the Session.cookieTimeout value. Although the php session was still valid, the expiration date on the session cookie does not get refreshed

The start time of the current session is available via CakeSession::$time . It will be false until the session has been started.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM