0

my code is this

<?php
echo '<font color ="red">sesion akan di destroy dalam 5 detik</font>';
$inactive = 5; 
ini_set('session.gc_maxlifetime', $inactive); 
session_start();
if (isset($_SESSION['testing']) && (time() - $_SESSION['testing'] > $inactive)) {
    session_unset();     
    session_destroy();   
    header("location: index.php");
}
$_SESSION['testing'] = time(); 

?>
Carl Binalla
  • 5,393
  • 5
  • 27
  • 46
seanmc
  • 31
  • 2
  • You can't use `header` after you have already output something (which you do on line one with `echo ...` – Nick Oct 19 '18 at 03:32
  • so what should i do i need to show text to wait 5 second sesion destroy and redirect to index .php – seanmc Oct 19 '18 at 03:35
  • You could do the redirection using javascript. See [this question](https://stackoverflow.com/questions/17150171/page-redirect-after-x-seconds-wait-using-javascript) – Nick Oct 19 '18 at 03:38
  • Enable the `error_reporting` on. `sesssion_start()` should always be at the start of the code. Syntax of `header("Location: index.php");` – Talk2Nit Oct 19 '18 at 04:23

0 Answers0