Glad you could log back in !
Keep in mind not all websites allow you to stay logged in without activity including Apple Support Communities.
If you are actively using a website and still get logged out, go to your Safari menu bar click Safari > Preferences then select the Privacy tab then click: Remove All Website Data. Quit and relaunch Safari.
If the same thing happens again, you may have a Safari extension or third party plug-in installed that's causing a conflict. It's easy to troubleshoot.
From the Safari menu bar click Safari > Preferences then select the Extensions tab. Uninstall one extension at a time, quit and relaunch Safari to test.
If it's not an extensions issue, try troubleshooting third party plug-ins.
Back to Safari > Preferences. This time select the Security tab. Deselect: Allow plug-ins. Quit and relaunch Safari to test.
If that made a difference, instructions for troubleshooting plugins here.