Enhance login and logout