diff --git a/client/js/controllers/auth_controller.js b/client/js/controllers/auth_controller.js
index 9db2a00..01c0143 100644
--- a/client/js/controllers/auth_controller.js
+++ b/client/js/controllers/auth_controller.js
@@ -24,6 +24,7 @@ class AuthController {
     }
 
     loginRoute() {
+        api.forget();
         topNavController.activate('login');
         this.loginView.render({
             login: (name, password, doRemember) => {
diff --git a/client/js/main.js b/client/js/main.js
index 468386c..0245e5e 100644
--- a/client/js/main.js
+++ b/client/js/main.js
@@ -30,8 +30,13 @@ const api = require('./api.js');
 api.loginFromCookies().then(() => {
     page();
 }).catch(errorMessage => {
-    page('/');
-    events.notify(
-        events.Error,
-        'An error happened while trying to log you in: ' + errorMessage);
+    if (window.location.href.indexOf('login') !== -1) {
+        api.forget();
+        page();
+    } else {
+        page('/');
+        events.notify(
+            events.Error,
+            'An error happened while trying to log you in: ' + errorMessage);
+    }
 });