PHP Session Automatic Cleanup method, phpsession cleanup _php tutorial

Source: Internet
Author: User
Tags config php php session

The method of regular automatic cleanup in PHP session, phpsession cleanup


Here are some examples of PHP setup session automatic cleanup, because the session default is 15 minutes automatically to the variable to clear the memory, but some time does not take effect, let's take a look.

After the configuration completes PHP the default PHP will generate the session to the/tmp directory, resulting in a lot of/tmp directory files, so you need to periodically clean up the session.

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 would CLE AR 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 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 timed task: [RO  Ot@hz scripts]# Echo ' #This is a config php session by:byrd at:2015-11-12 ' >>/var/spool/cron/root [root@hz scripts]# Echo' 0 3 * * 0/bin/bash/byrd/scripts/spehspsion.sh >/dev/null 2>&1 ' >>/var/spool/cron/root  

Note: Because this configuration modifies php.ini, the PHP process needs to be restarted.

The above is the whole content of this article, teach you how to implement the PHP set session automatic cleanup, I hope we have some gains from it.

http://www.bkjia.com/PHPjc/1071228.html www.bkjia.com true http://www.bkjia.com/PHPjc/1071228.html techarticle PHP Session Automatic cleanup method, phpsession clean the following to introduce to you the PHP set session automatic Cleanup example, because the session default is 15 minutes automatically to the variable to clear ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.