over 9 years ago
Hi Reader's,
Welcome to FindNerd, today we are going to discuss What is process to make custom session timeout in php ?
If you want to make the custom php session which will destroy automatic when page is not refreshing so long time.
you can take reference of bellow example
- <?php
- //firstly start session
- session_start();
- //if you want set 20 mins in seconds
- $destroy = 1200;
- // check to see if $_SESSION['timeout'] is set
- if(isset($_SESSION['timeout']) ) {
- $session_life = time() - $_SESSION['timeout'];
- //here check the session time which is set by you
- if($session_life > $destroy)
- {
- session_destroy(); header("Location: logout.php");
- }
- }
- S_session['timeout']=time();
- ?>
<?php //firstly start session session_start(); //if you want set 20 mins in seconds $destroy = 1200; // check to see if $_SESSION['timeout'] is set if(isset($_SESSION['timeout']) ) { $session_life = time() - $_SESSION['timeout']; //here check the session time which is set by you if($session_life > $destroy) { session_destroy(); header("Location: logout.php"); } } S_session['timeout']=time(); ?>
0 Comment(s)