在PHP中自动删除会话文件

I want to delete session files automatically in PHP.

I came to know that I have to change the following configurations in PHP.ini

  • session.gc_probability
  • session.gc_divisor
  • session.gc_maxlifetime

But I am not sure that what value to change in these properties.

Probably this example will help you

 <?php 
 // you have to open the session to be able to modify or remove it 
 session_start(); 

 // to change a variable, just overwrite it 
 $_SESSION['variable_name']='variable_value'; 

 //you can remove a single variable in the session 
 unset($_SESSION['variable_name']); 

 // or this would remove all the variables in the session, but not the session itself 
 session_unset(); 

 // this would destroy the session variables 
 session_destroy(); 
 ?> 

Using session_destroy(); function, created session files deleted from automatically.