I am trying to add different languages to my website by using sessions. But for some reason the language always stays on NL. My setup is like this:
header.php
(Only relevant code: )
include 'includes/connection.php';
include 'includes/lang.php';
<div id="lang-selector" class="dropdown">
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
<a href="<? echo $actual_link; ?>?lang=en" class="btn-selector">EN</a>
<ul>
<li class="active"><a href="<? echo $actual_link; ?>?lang=en">EN</a></li>
<li><a href="<? echo $actual_link; ?>?lang=fr">FR</a></li>
<li><a href="<? echo $actual_link; ?>?lang=nl">NL</a></li>
</ul>
</div>
Connection.php
(again only relevant code: )
session_start();
if ($_GET['lang'] != '') {
$_SESSION['lang'] = $_GET['lang'];
} else if ($_SESSION['lang'] == '') {
$_SESSION['lang'] = 'fr';
}
And my language file:
if($_SESSION['lang'] == 'nl') {
//footer
$copyright = 'Alle rechten voorbehouden';
}else if($_SESSION['lang'] == 'en'){
//footer
$copyright = 'All rights reserved';
}else if($_SESSION['lang'] == 'fr'){
//footer
$copyright = 'Tous droits réservés';
}
Why does my language always stay at nl? Even though I set the standard to fr in my connection.php. I also echoed the session value, and it says nl even when I add ?lang=fr manually to the url.