For the Mailcow UI you can set the SESSION_LIFETIME in data/web/inc/vars.local.inc.php
See here: https://docs.mailcow.email/manual-guides/mailcow-UI/u_e-mailcow_ui-config/
For SoGo, no idea, since I don’t use it.
But be aware that longer or even infinite session lifetimes are a potential security risk, and especially for the Mailcow UI, where you also login to your admin and domain admin accounts, I would not recommend doing this.