PHPでセッションファイルを自動削除したい。
PHP.ini で次の構成を変更する必要があることがわかりました。
- session.gc_probability
- session.gc_divisor
- session.gc_maxlifetime
しかし、これらのプロパティでどの値を変更すればよいかわかりません。
PHPでセッションファイルを自動削除したい。
PHP.ini で次の構成を変更する必要があることがわかりました。
しかし、これらのプロパティでどの値を変更すればよいかわかりません。
おそらくこの例はあなたを助けるでしょう
<?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();
?>
関数を使用してsession_destroy();
、作成されたセッション ファイルが自動的に削除されました。