Answer the question
In order to leave comments, you need to log in
Apache: how to remove old sessions from a custom directory
Good evening.
There is a site whose session files are not in the default directory, but in a separate directory. This is specified via .htaccess php_value session.save_path './../_sessions'
Files are saved to this directory. Only here's the trouble - the old sessions will not be deleted. The server config specifies a session lifetime of 10 minutes. But files from this directory are not deleted. Rights are enough.
I thought, maybe if it's a custom directory, then you need to delete it yourself? But something tells me it's wrong.
Tell me what could be the problem?
Answer the question
In order to leave comments, you need to log in
You won't believe it, but in a regular directory, session files are also deleted "by hand" +)
root@master:~# cat /etc/cron.d/php5
# /etc/cron.d/php5: crontab fragment for php5
# This purges session files older than X, where X is defined in seconds
# as the largest value of session.gc_maxlifetime from all your php.ini
# files, or 24 minutes if not defined. See /usr/lib/php5/maxlifetime
# Look for and purge old sessions every 30 minutes
09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete
[email protected]:~# cat /usr/bin/clear_sess.sh
#!/bin/bash
/usr/bin/find /var/lib/php52 -mmin +XXX -delete -print
# где XXX - количество минут (правда, у меня в днях mtime).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question