Some added code for handling login and logout of the client