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

keyur's avatar

Switching session storage

I have been running in production for last 2 months, but realized that I have been using file based session storage.

I think I would prefer to use redis or the database (mysql) instead.

If I just switch over, I am assuming that all sessions will be lost for people. Is there anyway to migrate the sessions in file over as well when making the switch?

Thanks!

0 likes
2 replies
Ionut's avatar

Some may get kicked out and forced to login again. Active sessions would be terminated I think. So you could do it late in the night if you don't want to piss off your users. Sessions expire after a certain amount of time anyways, so they would be forced to login again.

grahamd's avatar

If you wanted to retain this information, one avenue you might want to try is to see what the difference is when you switch your development version to say, mysql, then manually read through the file based sessions reading them and inserting them into MySQL.

Write this as an artisan command so in production you can mass migrate your file based storage over to mysql one evening, and should be quick and painless if your sessions don't extend to the millions.

As @Ionut said though, sessions by nature should be transient, so bin and start fresh.

Please or to participate in this conversation.