2

This is a very specific case.

When a user is already logged in, and then tries to visit the login page, /user/login, they are redirected to their user page, /user.

This is a problem for me and I need them redirected elsewhere. To be clear, I'm not asking the much-asked question "how to redirect users after login". I'm already using r3042login and login destination.

The case explained

My site runs http and https for authenticated users. What's happening is that the user access the http site, then clicks login, logs in on https. Then the user presses Back, or a bookmark to the http site and they are not logged in (because they have a different session). So then they hit log-in, which redirects to the https site, which thinks "ah, you're already logged in!", and presents the user page. The user page is not of any interest to my users.

Ideally I'd have it such that once the https session was started, any access to the http site bounced them over to https again, until they logged out.

  • You can create rule to redirect to other page if logged in user view the 'user/login' page. – Jayendra Kainthola Nov 8 '13 at 10:43
5

Ideally I'd have it such that once the https session was started, any access to the http site bounced them over to https again, until they logged out.

Maybe it can be done on web server side, but I'm not sure.

How to redirect logged in users accessing /user/login to specific page?

Don't forget you can alter any drupal_goto() calls:

/**
 * Implements hook_drupal_goto_alter().
 */
function YOURMODULE_drupal_goto_alter(&$path, &$options, &$http_response_code) {
  global $user;

  if (current_path() == 'user/login' && $path == 'user' && user_is_logged_in()) {
    // Redirect to front page.
    $path = '';
    drupal_set_message(t('Welcome back, %username!', array('%username' => $user->name)));
  }
}
| improve this answer | |
  • Its working perfectly !! – Reshma Jul 11 '14 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.