In case it helps others:
I got the error message upon submitting a form in the front end.
Changing the session handler to "php" in Joomla's configuration fixed the problem.
Warning: I don't know if changing from database to php as the session handler introduces other issues.