Note that there are some explanatory texts on larger screens.

plurals
  1. POcookies not being saved/read correctly
    text
    copied!<p>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:</p> <pre><code>&lt;?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'; } } ?&gt; </code></pre> <p>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?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload