I created a chat app without database using session this is my chat.php, called using rest api
$sid = $_GET["s"];
$new_name = $_GET["name"];
$new_msg = $_GET["msg"];
$client_length = $_GET["le"];
session_id($sid); //session
session_start(); //start session
$session_id = session_id();
if(empty($_SESSION['chat']))
{
$_SESSION["chat"] = array("0" => array(
"createdAt" => date("Y-m-d H:i:sa"),
"name" => "Room ".$sid,
"sid" => $sid));
}
array_push($_SESSION["chat"], array("name" => $new_name, "msg"=>$new_msg));
exit(json_encode($_SESSION["chat"]));
I want to free memory every 12 hours with destroy or clear all session
so when initiate
session_id($sid); //session
session_start(); //start session
the $_SESSION['chat']
back to empty, and also memory is free.
how to destroy or clear all session or session_id()
in php
sorry what i mean not session_destroy()
i want to make a task
or job
in php check if 12 hours after last reset of session, it will reset again and again.
in this case maybe you will think about session_destroy
it only happend if program knows the session_id
and already session_start
.
what if the program dont know about that, and want to reset the program's session?
that i mean
CMIIW about session_id
and session_start