0

I have the below code for disconnection. How may I modify this to auto disconnection if no activity for 5 mins, please?

<?php
    if(isset($_GET['action'])){
        if($_GET['action'] == 'disconnect'){
        session_destroy();
            header('location:./index.php');
            exit(); 
        }
    }
?>
Aquaholic
  • 863
  • 9
  • 25
  • 1
    pls use javascript to trigger – Ken Lee Nov 10 '21 at 09:27
  • 2
    PHP runs on the server before the HTML page is sent to the client so once the page is rendered there is no communication between php and the browser unless by user action or Javascript. To trigger that piece of code you'd need to use Javascript with some sort of timer as the activity is all within the browser. – Professor Abronsius Nov 10 '21 at 13:29
  • Perhaps [this is appropriate](https://stackoverflow.com/questions/23023916/how-to-implement-auto-logout-in-javascript) – Professor Abronsius Nov 10 '21 at 13:30

0 Answers0