Answers for "destroed session befor rigth leve page php"

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
2

php expire a session

//Ending a php session after 30 minutes of inactivity
$minutesBeforeSessionExpire=30;
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > ($minutesBeforeSessionExpire*60))) {
    session_unset();     // unset $_SESSION   
    session_destroy();   // destroy session data  
}
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity
Posted by: Guest on August-06-2019

Browse Popular Code Answers by Language