better login/session support

see commit messages