How to preserve language status using PHP sessions and cookies

TimeZone

New Member
I have this in my index.php:\[code\]<?php include_once 'file.php' ?>\[/code\]then I have \[code\]<html> some content </html>\[/code\]and I have this in file.php: \[code\]<?phpsession_start();header('Cache-control: private');if(isSet($_GET['lang'])){$lang = $_GET['lang'];$_SESSION['lang'] = $lang;setcookie("lang", $lang, time() + (3600 * 24 * 30));}else if(isSet($_SESSION['lang'])){$lang = $_SESSION['lang'];}else if(isSet($_COOKIE['lang'])){$lang = $_COOKIE['lang'];}else{$lang = 'en';}switch ($lang) { case 'en': $lang_file = 'lang.en.php'; break; case 'de': $lang_file = 'lang.de.php'; break; case 'es': $lang_file = 'lang.es.php'; break; default: $lang_file = 'lang.en.php';}include_once 'languages/'.$lang_file;?>\[/code\]I have those 3 files, I mean lang.en.php an so on...and it doesn't work, my page is empty, no text, why? What's wrong?lang.en.php contains\[code\]<?php$h1 ="HOME";$h2 ="ABOUT US";$h3 ="CONTACT";$h4 ="FAQ";$txt1 = "Here goes txt,Here goes txt,Here goes txt,Here goes txt, Here goes txt,Here goes txt,Here goes txt,Here goes txt, Here goes txt, Here goes txt,Here goes txt,Here goes txt.";?>\[/code\]I don't know what's wrong with this... What should I change? Can someone help me. Thanks.
 
Back
Top