PHP Code:
<?php
$lang = $_GET['lang'];
$lang_cookie = $_COOKIE['language'];
if (!empty ($lang_cookie)) {
if ($lang_cookie == 'english' || $lang_cookie == 'spanish') {
header ('location: '.$lang_cookie.'.php');
} else {
setcookie ('langauge','',time()-60);
}
} else {
if (!empty ($lang)) {
if ($lang == 'english' || $lang == 'spanish') {
setcookie ('language',$lang);
header ('location: '.$lang.'.php');
} else {
header ('location: page1.php');
}
} else {
echo '<a href="page1.php?lang=english">English</a><br />';
echo '<a href="page1.php?lang=spanish">Spanish</a><br />';
}
}
?>
This will be your first page. When you first go without a cookie, you'll see two links. I dunno what languages you want so I picked English and Spanish. After they click a link, a cookie called "language" will be set with a value of either "english" or "spanish", and they will be redirected to the page.
The next time they view the first page, an if statement checks for the existence of the cookie, and then whether the cookie value equals either "english" or "spanish". If these conditions are met, it redirects to the appropriate page.
I didn't test it but it should work.