a better way to managed loggedin and loggedout

Hi,
A better way to managed loggedin and loggedout.
Sorry it's a little messy ^^