Add persistent login feature.
Fix a wrong login behaviour.