Database/redis Gets Large And Slow After Extending Session Time Expiry

Dear CS-Cart communiy,

On my store in config.php file, I set users session expirey to end after 1 year. However, these settings seem to be effecting server performance and database size.

Firstly, I was using Redis to store sessions, but I started to experinece high latency which encreases day by day.

Then, I reverted back to use the Database to store my sessions. The problem is that my database is getting larger and larger.

Is there any thing I can do to extend session time without affecting database size and performance?

Note: I extened session time so that users stay logged-in whenever they opened my website. This is very important to me.

Thank you very much for your help!

No. The session data is stored in the DB and is referenced by the session_id from the user's browser cookie.

Why do you want a session to be alive for a year? Note that session info is updated on every page read. Hence if you store a year's worth of session info, you're updating a very large table that is heavily used. it will block all reads while it's doing the update unless you change the table format. But then every read will have to check whether the row is locked before allowing the read to occur. Hence you can build up a pretty long queue of requests by having a large sessions table.

The default 2 weeks is a reasonable session alive time. What is the problem you are trying to solve with extending the session alive time?

Thank you for your reply, tbirnseth. Actually, my main concern is to keep the user logged in as much as possible. Asking the user to login after two hours of inactivity would affect conversion. The default session time in config.php is set to 2 hours and not 2 weeks!

In otherwords, I want the user to stay logged in for a longer time.

That's fine. but going from 2hrs to 1 year is a bit exorbitant. Suggest you consider a more reasonable value like 24hrs. Who (what percentage of users) comes back after 24hrs to complete a purchase? Note that just because they are logged out doesn't mean their cart has been destroyed. Their cart should remain for 2 weeks.