Drupal login redirection

Submitted by Erik on Mon, 12/12/2011 - 20:51

One handy trick I've found is that when you're visiting a Drupal page and you notice that you're not logged in, you can simply add user?destination= into the URL right after the root of your Drupal site and keep the path. This means that




Then when you log in, you're brought back to the page you were viewing with no fuss.

I do this often enough that I decided to make it a bookmarklet.

javascript: function adduser() {
  var d = document,
  b = d.body,
  l = d.location;
  try {
    if (!b) throw (0);
    d.location.href = 'user?destination=' + l.pathname.substring(1);
  } catch(e) {
    alert('please wait');

This seems to work well in Firefox, Chrome and Safari on the Mac... and here's the condensed version ready to be copied into a bookmark.

javascript: function adduser() {var d=document,b=d.body,l=d.location;try {if (!b) throw (0);d.location.href='/user?destination='+l.pathname.substring(1);} catch(e) {alert('please wait');}}adduser();void(0);

Add new comment

The content of this field is kept private and will not be shown publicly.

Filtered HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <img src alt height width> <pre>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.