I had the same issue and I still wonder, that this security behavior still exists in nextcloud 20.0.1! It is a security leak for me, when a session never ends! To disable long running session you might to set those 3 parameters in your /config/config.php like this:
The main problem seems to be the cookie lifetime (parameter remember_login_cookie_lifetime). I changed it to zero. This ensures, that I need to login myself again, whenever I close the browser. You can change it’s value to same as session_lifetime to ensure, that the session does not die on browser crashes, but still dies on session timeout.
I can confirm this is still an issue on 27.1.1. With Firefox 115esr, the session for nextcloud never times out. The php.ini setting for session lifetime remains in the default for 8.1 of 24 minutes, e.g. session.gc_maxlifetime = 1440. Even so, I can sit down in the morning and the session in nextcloud is still active. Maybe a recent change triggered a regression?
One other possible contributing factor is I also have the IOS nextcloud app in use for syncing files. That access by my account may be what is responsible for nextcloud thinking my session is still active even though the browser and IOS app would have different session IDs. If it is just checking whether there was activity by the account, then that may explain the behavior. I haven’t looked at the source in nextcloud, so I have no idea what logic is being used, these are simply a few ideas based on what I see happening and possible factors…