I have a cookie to store the user’s language selection (there’s only Spanish or English). The site starts out okay (in Spanish) and if I change the language to English it changes BUT I can’t then get back to Spanish. The code is simple and similar to that which I used to change style sheets, but I cannot see what I’m doing wrong. My code is
<$lang = "es";
if ( isset($_COOKIE['lang']) ) $lang = $_COOKIE['lang'];
$php_self = $_SERVER['PHP_SELF'];
if ( $lang == 'en' )
echo '<a href="changelang.php?lang=es">español</a>';
else
echo '<a href="changelang.php?lang=en">english</a>';
and changelang.php is
setcookie('lang', $_REQUEST['lang'], time()+31536000, "/");
header("Location:".$_SERVER['HTTP_REFERER']);
I’m just wondering if having the variable and cookie name the same (ie lang) is what’s wrong.