Selecting a langauge for a website
Posted: Thu Feb 05, 2009 4:52 am
So here's the thing got a piece of code that checks if your swedish or not. It worked before but now somehow it never loads the page. I tested the thing with echo's if it dont jump in the if correctly. It works and puts out the correct information. Have tried somethings to go around this but it dont work. So I am looking if you guys can see if somethings wrong with the code.
Code: Select all
<?php
session_start();
$tmp = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
//$pos = strrpos($tmp, "-");
$lang = substr($tmp, 0, 2);
if(!isset($_SESSION['user_lang'])) {
if($lang == "sv" || $lang == "SV") {
header("location: se/");
echo "hej";
}
$_SESSION['user_lang'] = $lang;
echo "hej";
}
echo $lang;
?>