跳至内容
菜单
此问题已终结

Why do some sessions expire shortly after they are created?

I debugged the session_gc method, thinking it might be the root cause of the issue. Right away, I noticed a check involving random.random(). The condition if random.random() implies that there's a 0.1% probability (or 1 in 1000) of proceeding with the cleanup. This led me to consider the possibility that a session could be created and immediately fall under this rule for cleanup.

However, it attempts to check if the file was last modified before the specified date in last_week using os.path.getmtime(path). If the modification date is earlier than last_week, the file is deleted with os.unlink(path). It's important to note that this check is applied to all sessions. The session I created yesterday doesn't meet the condition of being earlier than last_week, so it should not be deleted.


形象
丢弃
相关帖文 回复 查看 活动
0
11月 15
5750
0
12月 21
3049
1
11月 16
9070
1
10月 21
3085
1
8月 15
7818