Purpose of folder matomo/tmp/sessions?

I am installing Matomo 5.0 RC4 and got it working I think.

What is the purpose of this folder “matomo/tmp/sessions”? Right now I got quite many files like " sess_vsgu9gq6ll7uc27sxxxxxxxx". Is the folder to store sessions in Matomo web application? Correct? Not the tracking data I assume?

According https://matomo.org/faq/new-to-piwik/faq_134/ and https://matomo.org/faq/how-to-install/faq_133/, sessions should be stored in dB by default. So my questions is then why are there so many files in this folder “matomo/tmp/sessions”?

I searched the archive and found that in earlier versions of Matomo you could add a config param to config.ini.php:

[General]
session_save_handler = “dbtable”

I assume this is old info and that you don’t need that anymore, since the article I pointed to said that sessions will be stored in dB by default.

I have my db located on a separate dB server and it seems like everything is working fine, I mean user tracking seems OK, I can log in and out from the web admin part of Matomo, I can download/install plugins etc but I can also see that the folder "matomo/tmp/sessions” is growing with “sess_xxxxxxx” files which makes me worried.

Hi @Fred_Ahlen
As this is a question about the deep working of Matomo, I think only @innocraft can reply…

Hi @Fred_Ahlen,
Was this a completely fresh installation of Matomo 5.0-rc4? Or was this an update to an existing installation?

Additionally, if you delete the session files from the server, do other new session files appear again?

P.S. I’m thinking that perhaps it’s possible that session files are created to store session data during the installation process since no database connection would exist yet.

1 Like

This was a fresh install of 5.0-rc4, I first created a dB on a separate server and used that in the install of the frontend.You are prob. correct that the session files in /tmp/sessions were created the first days, I’ve now removed these files and they are not re-created.The thing is that I’ve set this up in a loadbalanced environment where the load balancer was asking for a status msg by requesting a response from “root of my web site” every 2-3 seconds. This was generating a lod of these files and in the database. Now we have solved this by letting the nginx respond to these health checks.

These sessions (files in /tmp/sessions or table xx_session), they are related to users of Matomo web application, not the tracking part, right?

Since the session lifetime was not defined in config.ini.php, the lifetime was very long, hence the files/records in db is not removed. Is it safe to just delete the records in table xxx_session where lifetime is that large? Now I’ve changed the config so that session lifetime is 30 minutes (=1800).

This was answered in another post. Yes, it is safe to delete records in table “xxx_session”, the table is storing login session to Matomo and if there are still active sessions the users have to login again.

1 Like