Answer the question
In order to leave comments, you need to log in
The session is not saved, the reason?
The fact is that there is a language switcher
//session_start();
header('Cache-control: private'); // IE 6 FIX
if(isset($_GET['lang'])) {
$lang = $_GET['lang'];
// Register the session and set the cookie.
$_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 = 'english.php';
break;
case 'ru':
$lang_file = 'russian.php';
break;
default:
$lang_file = 'english.php';
}
include_once 'languages/'.$lang_file;
<a href="lang/en" class="footer-link pt-3">English</a>
<a href="lang/ru" class="footer-link pt-3 ml-4">Russian</a>
Answer the question
In order to leave comments, you need to log in
Why is this:
RewriteRule ^lang/(.*)?$ index.php?router=feed〈=$1 [L]
?
As a result, you send a request:
server.com/lang/ru
Apache transforms the request, and in php there will be a GET parameter:
$_GET['router'] = 'feed〈=en'
and in the script you check $_GET['lang '].
It may be easier to remove the rule in Apache (you may not delete it) and change the switch to:
href="?lang=en", because in this form, your handler expects data.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question