Drupal login redirection

By Erik, 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);