How do I know if unixtime php will expire?

How to find out how many seconds will be before php expires?

I am creating a web application where users can spend a lot of time typing in large text fields, but for security reasons I still want sessions to be timed after a fairly short period. I want to alert them if their session is about to end so they can save or take other actions to save it.

Any tips? thanks!

+2


a source to share


2 answers


it is very simple. you always have a session timeout which is 1440 seconds by default. to get the actual value you can use

$seconds=ini_get('session.gc_maxlifetime');

      



but there is another way, a better one. if your app receives text after the session ends, save that text in session, ask for a password, and then save the text as if it were a normal post.

+2


a source


You can store the expiration time in the database and then display a warning when it does. Or you can store the expiration time in a cookie and then have javascript that constantly checks if the session is about to expire.



+2


a source







All Articles