Answers for "php - destroy session while logout"

PHP
5

destroy session php

<?php 
 session_start(); // start session
 session_destroy();  // Delete whole session
// OR
unset($_SESSION['username']); // delete any specific session only
?>
Posted by: Guest on June-15-2020
0

php destroy session after some time

<?php
session_start();

// 2 hours in seconds
$inactive = 7200; 

$session_life = time() - $_session['testing'];

if($session_life > $inactive)
{  
 session_destroy(); 
}

$_session['testing']=time();
    
    echo $_SESSION['testing']; //prints NOTHING?
    ?>
Posted by: Guest on October-21-2021

Browse Popular Code Answers by Language