3
votes

Can I send my user back to the previous page when he logins in Drupal ?

He can login from different pages in my website. There is not only one login node. I would like to send him back to the page where he was.

Thanks

2

2 Answers

6
votes

Check out the Login Destination module. One of the configuration options for that module is "Return user to where he/she came from. (Preserve destination)", and I believe it's enabled by default.

Also helpful is LoginToboggan, which offers a few more login/registration tweaks. LoginToboggan includes an option for a "Login successful" message, which is good way to make sure your newly logged-in users don't get confused when they get redirected back to the previous page.

3
votes

$form_state['redirect'] is one way to do it. Set it in your submit handler. You could also use the destination URL param. URL?destination=X.