开发者

Help! Storing Session Cookies On Server, but there is no garbage collection

I am using PHP 5.2, and I am on a shared host, so I have decieded that i want to store the session cookies, in a folder of my own, but there doesn't seem to be any garbage collection. The cookies are stored there and never deleted. How can i fix this? the code I a开发者_StackOverflow中文版m using is

session_save_path('../example.com/sessions/');
ini_set('session.gc_probability', 1);


The other part of this is the session.gc_divisor config option. The default value of 100 will give you a 1% chance (gc_probability / gc_divisor) of garbage collection happening on any session start.

To force garbage collection to ALWAYS happen, try using:

ini_set('session.gc_probability', 100);
ini_set('session.gc_divisor', 100);

Once you've verified that they garbage collector is indeed working as intended, you should select reasonable values for these settings. 1 - 10% is fine.


What is your session.gc_divisor set to? If its 10000 the probability of the garbage collector starting will be pretty low. If its default, 100. Then there is a 1 in 100 chance the collector will start. Hit the page a ton of times, see if it clears.

Or set the probability to 100 or the divisor to 1. Either way, then it will run EVERY time. Which is overkill, but it should help you find out if its working. Then set it appropriately.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜