-4

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

yozawiratama
  • 4,209
  • 12
  • 58
  • 106
  • 3
    Possible duplicate of [How to kill a/all php sessions?](http://stackoverflow.com/questions/5193744/how-to-kill-a-all-php-sessions) – Raz Harush Apr 15 '17 at 16:49

1 Answers1

0

finally I use echo session_save_path(); and delete session file in that folder

yozawiratama
  • 4,209
  • 12
  • 58
  • 106