Destroy Session after some time - php login script - Phptpoint.com

Destroy Session after some time in PHP

Best PHP Training with Live Project in Noida Fee is only 7500/-Click here for FREE DEMO.

/ins>

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.

index.php

After login it redirects on home page

HomePage.php

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

logout.php

Keep Updating yourself