How to expire a PHP session?

How to expire a PHP session?

This is a very common requirement to expire a PHP Session If a user is inactive on page for more than say x time and redirect him to the Login page to Authenticate himself again.

The best possible solution for that is to Manage the Session timeout by your own, by your server. The existing PHP Session configuration options like session.cookie_lifetime or session.gc_maxlifetime are not reliable and might not work for you. They solve a different purpose.

So, lets see how to do it:

Hope this might help you. We will see in future posts that how to create a class that completely handles the sessions. So stay tuned and happy coding.

Leave a Reply

Your email address will not be published. Required fields are marked *