Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

agahi's avatar
Level 1

Thousands of files in session folder

I was moving my site to a new hosting and notice that there are thousands of files inside storage/framework/sessions.

Aren't they supposed to be deleted after ending a session? I don't actually use much sessions anywhere on the site since it is not a user-involved website.

0 likes
3 replies
Cronix's avatar

Do you have expire_on_close set to true in your session config?

1 like
Exiax's avatar
Exiax
Best Answer
Level 3

You probably haven't made changes to the session config, have you?

If it's something like

'lifetime' => 120,
'expire_on_close' => false,

your session files should be deleted after their lifetime expires. If you set "expire_on_close" to "true" they should be deleted immediatly on browser closing.

Maybe it's a problem with file permissions, or with the settings of your old host.

If so, there is a good chance the problem fixed itself after moving to a new host. I would clear the whole folder manually and check if the problem persists.

2 likes
ejdelmonico's avatar

@agahi With the session driver set to "file" and "expire_on_close" set to false, "lifetime" should take over with a default of 120 minutes.

Please or to participate in this conversation.