diff --git a/modules/ip_login/ip_login.module b/modules/ip_login/ip_login.module
--- a/modules/ip_login/ip_login.module
+++ b/modules/ip_login/ip_login.module
@@ -31,7 +31,7 @@
   // skip rest of this if user is logged in
   global $user;
   if ($user->uid != 0) return;
-
+  
   // skip rest of this if the admin has disabled IP login
   if (!variable_get('ip_login_enabled', 1)) return;
 
@@ -43,7 +43,7 @@
   $matched_uid = ip_login_check(ip_address());
   if ($matched_uid > 0) {
     $can_login_as_another_user = isset($_COOKIE[LOGIN_AS_DIFFERENT_USER]) ? $_COOKIE[LOGIN_AS_DIFFERENT_USER] : NULL;
-
+ 
     // for clarity about every scenario, use extensive logic
     if (is_null($can_login_as_another_user)) {
       // first time login for user, so log in automatically.
@@ -555,8 +555,18 @@
   // store whether this user can log back in automatically
   $can_login_as_another_user = _ip_login_can_login_as_another_user($user);
 
+  // retrive uid of the user can login by IP
+  $matched_uid = ip_login_check(ip_address());
+
+  if($matched_uid != $user->uid){
+    // in this case user logged by user/passwd would logout and so the system reset cookie to re-enable login by IP
+    $expire = time() - 3600;
+  } else {
+    // in this case user logged by IP would logout and try to login with another user
+    $expire = 0; // Cookie expires at the end of the session (when the browser closes).
+  }
+  
   // sets indicator to behaviour in hook_boot().
-  $expire = 0; // Cookie expires at the end of the session (when the browser closes).
   setcookie(LOGIN_AS_DIFFERENT_USER, $can_login_as_another_user, $expire, '/');
 
   if (!$can_login_as_another_user) {
