Sessions disappear on October CMS v2.1.21

Hi, everyone. My team have come across a bit of a problem. So, our sessions have suddenly stopped working. Mind you, no code was changed in these instances to anything new… They just stopped.

The things I’ve tried to do in order to fix the issue:

Using Laravel’s Session functions and Symphony’s session functions (We were using raw PHP $_SESSION).

Put session_start() on every php page, even if they did not necessarily have sessions on them (eg. partials). That produced an error. I even tried putting session_start() on the index.php file just to see if it could make any difference. None.

Grouped my routes into a web middleware. Nothing changed.

Checked the tmp folder where the session was saving the file. This is where I noticed that the session file disappears on a refresh and has 0 bytes of memory when it is created in the first place. So I assumed I must have been destroying the session somewhere. So I checked for any functions that could destroy a session and found none. There have not been any session_destroys, dds or trace_logs. I’m quite stumped as to what to do here.

It literally just gave out on us and we did not do any major updates or change any of the session code that was working before.

Can anyone help?

Never mind, guys. We just found out that one of the routes that was recently created for a plugin had a session destroy just hanging around on it’s own. Sorted.

Glad you got it sorted!

Another issue that can cause this is the storage/ directory not being writable. Here’s what the docs say about it

Invalid security token error when logging in

Check to ensure no missing subdirectories in the storage/framework path. You may need to add the sessions, cache and views directories.