Database logging users out
You cannot assume that a user stays logged in forever.  Glitches occur everywhere, especially in networks.  You must code to recover from such.

When running in a browser, each page is necessarily a separate database connection.  Code accordingly.