The only way you can get logged out is if your Danbooru cookies get cleared. Make sure there's nothing in your browser that could be clearing your cookies.
There is a known issue where if you visit https://testbooru.donmai.us
your Danbooru cookies will get cleared (so don't go there unless you want to get logged out). If you happen to be testing something on Testbooru, that might be it.