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

Mick79's avatar

Database Vs Cookies Vs Redis - What's best for sessions?

I've recently had to change how I handle my sessions as I'm now running across many boxes with HA Proxy in front of them all.

I've opted to use the database for sessions but basically I'm ignorant to the pros and cons of the other options. My priority is speed. What should I use?

0 likes
5 replies
martinbean's avatar

@mick79 The database is probably the least optimal driver to use for sessions are you’re now increasing the load on the database.

Redis would be a better option as it lives in memory so reading is going to be fast.

Mick79's avatar

@martinbean Given that my experience with redis is limited - Where do cookies rate? better than DB?

And are they still viable in a HA Proxy / multiple boxes setup?

jlrdw's avatar

@Mick79 file based is usually fine and fast. However if you have to go with load balancing then use database. Redis I am not sure about. But do a search on redis with load balancing.

Of course you know an API will be different.

Mick79's avatar

@jlrdw

Of course you know an API will be different.

Unsure what that last sentence means?

Please or to participate in this conversation.