Hello, there.
I've been reading faq434-2036 about Session Handling but still can work this issue out...
I am converting a static site into a dynamic one. One of the features involves i18n.
Example: I have a link on every PHP page which allows the user to switch languages in this way:
In this way, I am using GET to send the [tt]lang[/tt] variable to the page itself when reloading.
On top of every site's page I include the following
...where I handle the session in the following way:
Doing this, I set Spanish as the default language or set the session variable to the language specified in the [tt]lang[/tt] variable.
I require the same code snippet on every page but when navigate to other page, the language is not set and drops to the default: Spanish....
I assume it's my logic proble, 'cause I've read PHP documentation about Sessions and it's very simple
and it makes me feel still more stupid
Thanks In Advance
Arlequín
arlequin_AT_montevideo_DOT_com_DOT_uy
I've been reading faq434-2036 about Session Handling but still can work this issue out...
I am converting a static site into a dynamic one. One of the features involves i18n.
Example: I have a link on every PHP page which allows the user to switch languages in this way:
Code:
<a href="<?=$_SERVER['PHP_SELF']?>?lang=es">español</a>
Code:
<a href="<?=$_SERVER['PHP_SELF']?>?lang=en">english</a>
In this way, I am using GET to send the [tt]lang[/tt] variable to the page itself when reloading.
On top of every site's page I include the following
Code:
<?
require_once "inc/sess.php";
?>
...where I handle the session in the following way:
Code:
<?
/// sess.php
session_start();
$lang = $_GET['lang'];
if(!isset($_SESSION['language']) ||
$lang!=$_SESSION['language']) {
if( isset($lang) ) {
$_SESSION['language'] = $lang;
} else {
$_SESSION['language'] = 'es';
}
}
?>
Doing this, I set Spanish as the default language or set the session variable to the language specified in the [tt]lang[/tt] variable.
I require the same code snippet on every page but when navigate to other page, the language is not set and drops to the default: Spanish....
I assume it's my logic proble, 'cause I've read PHP documentation about Sessions and it's very simple
and it makes me feel still more stupid
Thanks In Advance
Arlequín
arlequin_AT_montevideo_DOT_com_DOT_uy