I've made a little PHP website which works in three different languages. These languages can either be set through a $_GET or a $_COOKIE with $_GET being the first to be checked so it can overwrite a cookie if needed. If I determine the language I need, I include a file which holds all my translations and set a cookie for future use. The code looks something like this:
<?php
if (isset($_GET['language'])) {
// if language in $_SET is English, load english translation and set a cookie for the future.
if ($_GET['language'] == 'EN') {
setcookie('language','EN', time()+31536000);
include 'tekstenEngels.php';
// if language in $_SET is French, load french translation and set a cookie for the future.
} elseif ($_GET['language'] == 'FR') {
setcookie('language','FR', time()+31536000);
include 'tekstenFrans.php';
// lastly if language in $_SET is Dutch, load Dutch translation and set a cookie for the future
} else {
setcookie('language','NL', time()+31536000);
include 'tekstenNederlands.php';
}
// the same but for cookies in case this isn't the first visit
} elseif (isset($_COOKIE['language'])) {
if ($_COOKIE['language'] == 'EN') {
include 'tekstenEngels.php';
} elseif ($_COOKIE['language'] == 'FR') {
include 'tekstenFrans.php';
} else {
include 'tekstenNederlands.php';
}
}
?>
This works fine on my locahost but it doesn't seem to write/read the cookies correctly when used on my webserver. Any ideas what I could be missing/doing wrong?