Multiple logi and log out pages

By DanMaitland - November 9, 2010 - edited: November 10, 2010

I have a drop down list with English and French and it's called language.

Re: [Dan Maitland] Multiple logi and log out pages

By Jason - November 10, 2010

Hi Dan,

In the example below it checks to see what the value of the language field is for the $CURRENT_USER and sets a redirect url.

NOTE: you may need to change some variable names to match what you have in the database.

// redirect on success
if (@$_SESSION['lastUrl']) { $postLoginUrl = @$_SESSION['lastUrl']; }
else if ($GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL']) {
if($CURRENT_USER['language']=="french"){
$postLoginUrl="/login/login-fr.php";
}
else{
$postLoginUrl="/login/login.php";
}


}
else { $postLoginUrl = thisPageUrl(); }
$redirectUrl = $GLOBALS['WEBSITE_LOGIN_POST_LOGIN_URL'];

unset($_SESSION['lastUrl']);
redirectBrowserToURL("$postLoginUrl");
exit;


This code should take care of redirecting after login. It won't take care of redirects to the profile page, logging off, etc.

Making a site bilingual can be a very complicated processes. If you require more help on this, I would suggest sending an email to consulting@interactivetools.com and we can help tailor this code directly to your needs.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason,
In that last piece of code you put up, is $postloginUrl="/login/login-fr" the page that the user will be redirected to once they have logged in? and couldn't this same piece of code work for the logout process?

Re: [chris] Multiple logi and log out pages

Thank you very much Chris but for some reason it doesnt matter which section which user logs out (english or French) they both redirected to the English section once they log off.

Re: [Dan Maitland] Multiple logi and log out pages

By Jason - November 12, 2010

Hi Dan,

Does the login work correctly or does it always redirect to the English page as well? If you want to fill out a second level support request here:

https://www.interactivetools.com/support/email_support_form.php

I can take a quick look and see what's going on.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
The login works perfectly it's just the piece of code that Chris gave me that doesn't work properly. From looking at it I don't see why it doesn't work, it just redirects back to the english home page no matter whether you french or english.

Re: [Dan Maitland] Multiple logi and log out pages

By Jason - November 12, 2010

Hi Dan,

I would suggest filling out a 2nd Level Support Request here:
https://www.interactivetools.com/support/email_support_form.php

and we can take a closer look at this.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Dan Maitland] Multiple logi and log out pages

By Jason - November 16, 2010

Hi Dan,

I found the problem. What was happening in the logoff function is that this code:
// unset current user
$CURRENT_USER = false;


was appearing both before AND after your if statement. This code destroys the $CURRENT_USER variable which is being used in the if statement. This is why is was always redirecting you to the English page. I removed it so that it only appears after the if statement and is seems to work fine now.

Hope this helps.
Jason
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/