PHP でセッションのタイムアウトを設定するには
session.gc_maxlifetime session.gc_probability session.gc_divisor
の3つをこねくりまわせば有効期限を制御することができる。
この中で一番大切なのは、session.gc_maxlifetimeの設定値。
session.gc_maxlifetimeにセッションの有効期限を秒数で設定すればいい。
通常は(session.save_handlerのデフォルトはfileなので)セッション情報がサーバ上に次々とファイルを作られる。
cronなどでこのファイルを定期的に消してくれる。
設定を入れることで、それらセッションが有効期限をきたら無視してくれる。
phpサイトには次の通り
int session_cache_expire ([ string $new_cache_expire ] )
you can change the max lifetime for a session with the function ini_set(). <?php ini_set("session.gc_maxlifetime", "18000"); ?> This will set the max lifetime of the script to 5 hours. You have to use this in every script that you want to change the default lifetime for. if you want to know the lifetime of your current script, you can use: <?php echo ini_get("session.gc_maxlifetime"); ?>
参考資料