The php session is automatically cleared regularly. In php, the session is automatically cleared on a regular basis. in phpsession cleanup, I will introduce the example of setting the session regular automatic cleanup in PHP, the default value of session is to automatically clear the variables for the php session in 15 minutes.
Next, I will introduce you to the example of setting the PHP session to automatically clean up regularly, because the default session is to automatically clear the variables for 15 minutes, but some time does not take effect, let's take a look.
After php is configured, php will generate the session to the/tmp directory by default, resulting in a large number of files in the/tmp Directory. Therefore, the session needs to be cleaned regularly.
Modify php. ini:
[Root @ hz scripts] # grep "session. save_path = "/usr/local/php/lib/php. ini; session. save_path = "N;/path"; session. save_path = "N; MODE;/path"; session. save_path = "/tmp" session. save_path = "2;/tmp/session" [root @ hz ~] # Cat/byrd/script/Cleartmpsen. sh #! /Bin/bash # Version: 1.0 # Author: Byrd # Site: www.t4x.org # Contact: root # t4x.org # This is script will clear php session before 3 hours. I = "0 1 2 3 4 5 6 7 8 9 a B c d e f" for byrd in $ I; do for x in $ I; do mkdir-p/tmp/session/$ byrd/$ x; done chown-R bywww: bywww/tmp/session chmod-R 1777/tmp/session find/tmp/session-amin + 180-exec rm-rf {}\; if ['grep' session. save_path = '/usr/local/php/lib/php. ini | wc-l '-eq 3]; then sed-I's #; session. save_path = "/tmp" #; session. save_path = "/tmp" \ nsession. save_path = "2;/tmp/session" # g'/usr/local/php/lib/php. ini else exit 1 fi scheduled task: [root @ hz scripts] # echo '# This is a config php session BY: byrd: 2015-11-12 '>/var/spool/cron/root [root @ hz scripts] # echo '0 3 ** 0/bin/bash/byrd/scripts/speheat Sion. sh>/dev/null 2> & 1'>/var/spool/cron/root
Note: Because this configuration modifies php. ini, you need to restart the php process.
The above is all the content in this article. we hope you will gain some gains from this article.
In the following article, we will introduce you to the example of setting regular automatic session cleanup for PHP, because the default session is to automatically clear variables within 15 minutes...