Possible Duplicate:
Accessing $_COOKIE immediately after setcookie()
So I am using the following code below to add multilingual features to my site:
if(isset($_GET['lang']) && $_GET['lang'] != ""){
setcookie("lang", $lang, time()+360*360*3600);
}elseif(!isset($_COOKIE["lang"]) || $_COOKIE["lang"] == ""){
setcookie("lang", "en", time()+360*360*3600);
}
include 'lang/'.$_COOKIE["lang"].'.php';
Now when this code gets executed the first time it fails to find the `$_COOKIE["lang"] and therefore fails to open the file, however after when I refresh the page it loads just fine. I was wondering what I am doing wrong?