Advertisement:

Author Topic: problem with returning to referer page after login  (Read 5432 times)

Offline chadness

  • Sophist Member
  • *****
  • Posts: 1,025
  • Gender: Male
    • technoadvice.com
problem with returning to referer page after login
« on: February 17, 2005, 03:58:19 PM »
Additional on login/logout redirection.

I think by default the  mod_smf_login module will point to the mambo index page after login/logout. To redirect you back to the page where you login/logout, in MOS_SMF.php change this line from:

Code: [Select]
$_SESSION['login_url'] = $mosConfig_live_site;
to
Code: [Select]
$_SESSION['login_url'] = mosGetParam( $_SERVER, 'HTTP_REFERER', null );
and from:

Code: [Select]
$_SESSION['logout_url'] = $mosConfig_live_site;
to
Code: [Select]
$_SESSION['logout_url'] = mosGetParam( $_SERVER, 'HTTP_REFERER', null );
I am no php genius but I think it works! (that is after hours of experimenting)  ;D
If you load this code from the combined readme thread (click link above for the source of this), you may run in to a problem if people log in to your site while in a subdirectory.  For instance, go to your registration page, which should be in the subdirectory "directory" and login there.  You will be returned to the registration page, but if click a relative link from there (such as a "home" link on your main menu) you may end up at yoursite.com/directory/index.php.  For me, that link seems to be my regular site, but anything off of a a relative path from there is messed up (several images, my admin login, etc.).

I caught this on my test site, and I'd be curious if anyone else can verify this.  Just something to watch out for.