I'm using a fairly plain 1.3.8a and wanted to offer my experience today. I hadn't read this thread at all and went about things slightly differently, though by the looks of things I could have used this navigationHistory object referred to. I'm using a modified approach to that seen on http://www.zen-cart.com/forum/showth...login+redirect, which uses the observer/notify feature (http://www.zen-cart.com/wiki/index.p...Observer_Class) and the fact that includes/modules/pages/login/header_php.php fires a NOTIFY_LOGIN_SUCCESS notification event on successful login.

My situation is that, on entry to a custom tpl_somethingorother_default.php page, I want to ensure the customer is logged on. If I redirect to logon, I want them to come back to the current page after logon.

This is not a global solution, but one designed to be used in a specific module, because it relies on a custom session variable login_redirect being set, though I'm sure it could be adapted.

1/ Create file includes/classes/observers/login.redirector.php:

PHP Code:
# see http://www.zen-cart.com/forum/showthread.php?t=135312&highlight=login+redirect
class LoginRedirector extends base {

LoginRedirector() {

$zco_notifier->attach($this, array('NOTIFY_LOGIN_SUCCESS'));

update(&$class$eventID) {
# If the login_redirect session variable was set, redirect to it.
if (isset($_SESSION['login_redirect'])) {
$destination $_SESSION['login_redirect'];
2/ Create file includes/auto_loaders/config.loginRedirect.php (perhaps the numbers 10 and 90 could be improved, I don't care about their values much as they don't depend on the order of any other instantiation):

PHP Code:
[10][] = array('autoType'=>'class',
$autoLoadConfig[90][] = array('autoType'=>'classInstantiate',
3/ Then, in the module you want to redirect from (this is on entry to my Warranty form's header_php.php. In this flow of logic, I want to ensure the customer is logged in before proceeding):

PHP Code:
  if (!(isset($_SESSION['customer_id']))) {
$_SESSION['login_redirect'] = zen_href_link (
'order_no=' $_REQUEST['order_no'], 'SSL' );
zen_redirect(zen_href_link FILENAME_LOGIN'''SSL' ));
So as a visitor tries to go to my warranty form, the first time through the template's header_php.php, if the customer_id is not set in the session, it will set a session login_redirect variable recording where to redirect back to after login, and redirect to login. Once login is complete, the observer jumps in, notices the login_redirect session variable, and redirects back to my warranty form.

You could set $_SESSION['login_redirect'] to any URL you like, and redirect to login, and it will redirect to your URL on successful login.

I'd welcome any corrections.