How i can create session when first time wordpress plugin load and destroy session after 1 minute

session_start();
$time = $_SERVER[‘REQUEST_TIME’];
$timeout_duration = 1*60;
$_SESSION[‘traffic_current_ip’] = $_SERVER[‘REMOTE_ADDR’];
$_SESSION[‘trafficsource’] = $_SESSION[‘traffic_current_ip’] ;

// Set the session timeout for 1 minute
if (!empty($_SESSION[‘trafficsource’])) {

echo “Session created <pre>”;
print_r($_SESSION);

}

$_SESSION[‘trafficsource’] = $time;
elseif(isset($_SESSION[‘trafficsource’]) && ($time – $_SESSION[‘trafficsource’]) > $timeout_duration) {

$_SESSION_DESTROY();
echo “test yes capture but time crossed<pre>”;
print_r($_SESSION);

}

Read more here:: How i can create session when first time wordpress plugin load and destroy session after 1 minute

Leave a Reply

Your email address will not be published. Required fields are marked *