Destroy Session after some time - php login script -

Destroy Session after some time in PHP

PHP Summer Training/Internship with 2 Live Projects in Noida Fee is only 5500/-Click here to Book Your Seat


Destroy Session after 5 minutes in PHP

By default the expiry time of any particular session that is created is 1440 secs i.e (24*60).
ie 24 minutes around
But in some cases there is necessity to change this default time .
There are two ways of doing this :
either we can make changes in the php.ini file, and change the configuration .
But in this case the default time for all the sites working on that server will change.

There is another method to getrid of this.
we can logically change the destroy time of session.
here at the time of creation of session we calculate the system current time .
and as the user browse to different pages of the script will check for the expiry time i.e
is explicitly declared as session-expiry(time previously noted at the time of session creation + the time for which you want your session to be maintained). The session get destroyed at
that particular time and redirect the user to the homepage of that script.


After login it redirects on home page


After 5 minutes destroy session, logout and redirect on home page.


Latest Trending Technologies