UPDATE: login and logout better
ADDED: the actual js file
UPDATE: login is better
UPDATE: login is better