开发者

Does ini_set('session.save_path', 'custom path'); effect the session garbage cleaner?

开发者 https://www.devze.com 2023-02-01 10:45 出处:网络
Does ini_set(\'session.save_path\',\'custom path\'); effect the session garbage cleaner? As I\'m setting a custom directory for the sessions, because I\'ve read from various php security guides, that

Does ini_set('session.save_path', 'custom path'); effect the session garbage cleaner?

As I'm setting a custom directory for the sessions, because I've read from various php security guides, that setting a custom directory on shared hosting for sessions; can improve session security.

But the problem is I've read somewhere that PHP does/handles the session garbage cleaning only when the session_save_path is the default and not modified (ie. using a custom directory)? - is this true, if so is their a solution for this?.

(take into consideration I'm using shared ho开发者_高级运维sting).

Appreciate all help!


The garbage collector kicks in before control is handed over to your script, so when the GC kicks in, the save_path set in php.ini will be in effect, not the path you're overriding with.

Essentially, you cannot use the default garbage collector if you override the save_path from within your scripts. The session files will be stored in the override directory, but the GC will look in the previous dir, which would now have no session files in it.


There are some distributions that set session.gc_probability to 0 and clean up old sessions using a cron job. In such a configuration, a custom path effectively prevents clean up. If this is the case with your installation, set session.gc_probability and session.gc_divisor to values grater than 0.

0

精彩评论

暂无评论...
验证码 换一张
取 消