'Invalid serialization data for DateTimeImmutable object' error after updatin 5.0.5 => 5.0.8

I don’t think this is a bug or really anything related to the version update. Reason why I wanted to write about this is that according to Google, similar error/problem has been around quite some time and I was not able to find fix for this. So I thought I document this to help if someone else runs into this problem.

Problem: ‘2024-05-30 05:27:39 error: [Error] Invalid serialization data for DateTimeImmutable object in /var/www//vendor/cakephp/cakephp/src/Http/Session.php on line 367’

Fix: Find php session directory (in my case /var/lib/php/sessions/) and remove session file(s).

In my case this problem was only visible to one user, so I just removed one session file.