How to redirect a user to previous page after successful login?
The following implementation of hook_user_login() will override the redirect path set by user_login_submit().

As with the default behavior, setting the destination in the query string overrides this redirect.

&lt;?php

/**
 * Implements hook_user_login().
 */
function mymodule_user_login(&amp;$edit, $account) {
  $edit['redirect'] = $_GET['q'];
}