If a logged-in user does not log out of his account and the session thus never gets destroyed ie (logout-page.php), would the session die when the browser closes? Reason I ask is if the user does not log out when browser closed, when browser re-opened, the site says user is still logged in.
No. The session is managed on the server side and the client does only get the session ID for identification. Closing the browser would only destroy session cookies (i.e. cookies that is only valid during the current browser session) that hold the session IDs but not the associated sessions. If the same session is used after re-opening the browser, the session’s cookie is probably not a real session cookie but a persistent cookie. You can adjust that setting session.cookie_lifetime to 0
.
Is it best to keep the user logged in (ie login.php - enter details once->start session) rather then requiring user to keep logging in, as mentioned if an error occurs on my scripts or if certain pages user accesses I destroy the session (ie log them out)?
In general, as you use the session for a user authentication purpose, you should only demand for re-authentication if you have doubts about the current user’s authentication (e.g. user agent changed) or if you want an additional authentication confirmation (e.g. privilege changes, as evidence for non-repudiation, etc.).