Refactor sqlite3 usage and work on sessions + autologin if valid session and cookie