0
我有一段代碼,應該重定向用戶,如果有會話沒有餅乾..PHP餅乾的問題,不包括語言文件
if (isset($_GET['lang'])) {
if (in_array($_GET['lang'], $jezici)) {
$lang = $_GET['lang'];
// register the session and set the cookie
$_SESSION['lang'] = $lang;
setcookie("lang", $lang, time() + (3600 * 24 * 30));
} else {
$lang = 'hr';
$_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 if (empty($_GET['lang']) || !isset($_GET['lang'])) {
$trenutni_file = basename($_SERVER['PHP_SELF']);
?>
<META http-equiv="refresh" content="0;URL=http://<?php echo $domena; ?>/<?php echo $trenutni_file; ?>?lang=hr">
<?php
exit();
}
?>
這是我包括它的index.php
$langArray = include 'lang/'.$lang.'.php';
但有時我得到這個錯誤未能包括lang/.php ...這段代碼顯然沒有做正確的..如果在會話中沒有設置cookie,我會將用戶重定向到index.php?lang=hr
...任何幫助?
沒有'include'在發佈的代碼。你確定語言變量是否在執行時被設置? – kero
@ user3002173將示例代碼放入您的問題中,而不是評論。另外,你是否正確使用'session_start()'? –