文章日期 10 月, 2008

PHP 的 Session 預設是 1440 秒 (24分鐘) 清空一次,但是如果更改了session.save_path 設定,Session garbage collection 就不會再動作了。
這時候就要用 crontab 手動清理:
cd /path/to/sessions; find -cmin +24 | xargs rm
註:+24 代表檔案更新日期為 24 分鐘前
以下是官方說明:
; NOTE: If you are using the subdirectory option for storing session files
;       (see session.save_path above), then garbage collection does *not*
;       happen automatically.  You will need to do your own garbage
;       collection through a shell script, cron entry, or some other method.
;       For example, the following script would is the equivalent of
;       setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
;          cd /path/to/sessions; find -cmin +24 | xargs rm

關於這裡

這個部落格分享了哇寶在電子商務領域的技術及資訊,希望能讓更多人一起為台灣的網路產業加油。