I don't know much about PHP, so could be small problem - but the changed code helped my site to be spidered better, but now the Phpecho files only display after reloading a 2nd time...strange! This was the working code before: <?php if (!isset($_COOKIE['lang'])) { if ($_SERVER["HTTP_ACCEPT_LANGUAGE"] == "ja") { header("Location: /setlang.php?lang=ja"); } else { header("Location: /setlang.php?lang=en"); } } //language stuff if ($_COOKIE['lang'] == "en") { //english array $l = array( 1 => "Logged in as", ...etc Code (markup): This is the changed code: <?php function change_lang($la) { if(strlen($la) == 2) { setcookie('lang', $la); } } if (!isset($_COOKIE['lang'])) { if ($_SERVER["HTTP_ACCEPT_LANGUAGE"] == "ja") { change_lang("ja"); } else { change_lang("en"); } } //language stuff if ($_COOKIE['lang'] == "en") { //english array $l = array( 1 => "Logged in as", Code (markup): Can anyone spot the problem? Thanks
With setcookie('lang', $la); you are sending the cookie header and setting the language, but that cookie will only be read on subsequent page request. That's why the previous code was doing header("Location....") (the cookie was probably set there and there was a redirect back to calling page, to read that cookie) Maybe you could try something like this: function change_lang($la) { if(strlen($la) == 2) { setcookie('lang', $la); } } if (!isset($_COOKIE['lang'])) { if ($_SERVER["HTTP_ACCEPT_LANGUAGE"] == "ja") { change_lang("ja"); $lang = "ja"; } else { change_lang("en"); $lang = "en"; } } else $lang = $_COOKIE['lang']; //language stuff if ($lang == "en") { PHP: Replace all further $_COOKIE['lang'] with $lang