Forum Moderators: coopster
// includes/assign_language.php
// THIS FILE APPEARS IN THE HEADER OF EVERY PAGE
// THIS PAGE ASSIGNS A LANGUAGE
// THIS PAGE HAS NOTHING TO DO WITH THE CONTENT THE USER SEES - ONLY THE LANGUAGE THEY SEE IT IN
// AND ONE ISN'T SET, SET ONE
if(isset($_COOKIE['language_preference']) == FALSE)
{
// SET COOKIE EXPIRY TIME
$number_of_days = 1825; // APPROX. 5 YEARS
$date_of_expiry = time() + 60 * 60 * 24 * $number_of_days;
Set their language cookie here...
// REFRESH THE PAGE TO UPDATE THEIR LANGUAGE
header('Location: http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);
}
// SET THE LANGUAGE ID FROM THE COOKIE
$languageid = $_COOKIE['language_preference']; if ($_COOKIE != set)
break;
header('Location: http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); if ($_COOKIE != set)
break;
Function Sessionc()
{
$_SESSION['test'] = 1;
if($_SESSION['test']=1) {
echo "please turn on browser cookies. Meanwhile, we will use your session";
$SESSION['use'] = 1;
} else {
die('Error, cookies have been disabled and session is not responding. To fix please activate cookies');
}
}
$_COOKIE['test'] = 1;
if($_COOKIE['test']!=1) {
Sessionc;
}
If($_SESSION['use']=1) {
INCLUDE "path to session code file";
} else {
INCLUDE "path to regular cookie file";
}
if (isset($_COOKIE['PHPSESSID'])) {
// do your cookie logic
}
else {
// output ALL URL's dynamically, and append every URL with ?language=selected language
}