Another solution found in the link in the answer by Niraj Niroula:
If you want to keep the Delete cookies and site data when Firefox is closed option enabled, click on the Manage Exceptions button and add localhost (with the protocol and port) to the exceptions list: