Hello , I'm making a multi language website and i decided to use sessions to remember the current language , overall it works as its supposed to , but there is one bug that i can't fix . 1) i load the page and it displays properly in Bulgaria 2) i add '&lang=en' to test if its working properly , and it does 3) when i remove the '&lang=en' and its back to Bulgarian when its not supposed to its supposed to stay in English
here is what is in the header of the page
if(isset($_GET['lang'])){
$lang = htmlspecialchars($_GET['lang']);
lang($lang);
}
if(!isset($_SESSION['slang'])){
lang('bg');
}else {
lang($_SESSION['slang']);
}
and here is my function that handles the language switching
function lang($lang=''){
if($lang=='bg'){
$_SESSION['slang'] = 'bg' ;
include_once('./includes/bulgarian.php');
}
if ($lang == 'en'){
$_SESSION['slang'] = 'en' ;
include_once('./includes/english.php');
}else {
$_SESSION['slang'] = 'bg' ;
include_once('./includes/bulgarian.php');
}
}
if someone can explain me why this is happening and how i can fix it it would be great Thanks