trying to get the login and logout to work smoothly. Nearly there, but logout seems to not work immediately.