Why cant I change cookie?
If you chose a language you cant change. You have to empty your cookies if you want to change language. Why is that?
if (isset($_GET['setLang']) && $_GET['setLang'] == 'en'
|| isset($_COOKIE['setLang']) && $_COOKIE['setLang'] == 'en') {
setcookie("setLang", 'en', time()+(3600*12)); //expires in 12 hours
include('language/en/common.php');
}
elseif (isset($_GET['setLang']) && $_GET['setLang'] == 'se'
|| isset($_COOKIE['setLang']) && $_COOKIE['setLang'] == 'se') {
setcookie("setLang", 'se', time()+(3600*12)); //expires in 12 hours
include('language/se/common.php');
}
else if (isset($_GET['setLang']) && $_GET['setLang'] == 'fr'
|| isset($_COOKIE['setLang']) && $_COOKIE['setLang'] == 'fr') {
setcookie("setLang", 'fr', time()+(3600*12)); //expires in 12 hours
include('language/fr/common.php');
}
// default language is english
else {
include('language/en/common.php');
}
You certainly can change cookies. You can’t change languages using the logic you have there because the way you’ve written it, an existing setting in
$_COOKIEwill always override a setting in$_GET(except foren, where$_GETwill be checked first, so right now you should be able to switch toenif you started with another language). You need to do all checks against$_GETfirst, then all checks against$_COOKIE, if you want to be able to change languages.