1
votes

I'm using a database sessions driven website with CakePHP. I can see a expires field with some numbers in it for each record. I assume that's how Cake knows when to timeout a session.

The thing is that I don't understand very well what those numbers exactly mean, or if I can use them somehow. For example, making a query and getting the value of the expires field of a record, how can I know how much time is left until that session expires? Or if it should be expired already?

1

1 Answers

3
votes

It's a unixtime stamp, see http://en.wikipedia.org/wiki/Unix_time

You can get the time difference to this moment by something like:

$seconds = $session['Session']['expired'] - time();

Or to check if it already expired:

if ($session['Session']['expired'] <= time()) { /*...*/ }