I have to php files and want to send the $_lang to the other page by using session, whether i use session_start() in both file or just only in the first file the $_lang can not be sent. I have same problem if i use cookie
js file:
$(document).ready(function(){
cat();
function cat(){
$.ajax({
url: "action.php",
method: "POST",
data: {menu:1},
success: function(data){
$("#get_menu").html(data);
}
})
}
});
first php file:
<?php
session_start();
//get current url
$goback=$_SERVER['HTTP_REFERER'];
$GLOBALS['_lang']=$_GET['lang'];
$_SESSION['lang']=$_lang;
echo $_SESSION['lang'];
//go to current url
header("location:$goback");
?>
here is the code for second file.
<?php
include ('db.php');
$_lang=$_SESSION['lang'];
//$_lang= 'us';
if(isset($_POST["menu"])){
//function display_menu(){
$category_query="SELECT * FROM menu WHERE parent_id=0";
$run_query=mysqli_query($con,$category_query);
if(mysqli_num_rows($run_query)>0){
while($row=mysqli_fetch_array($run_query)){
$menu_id=$row["menu_id"];
$menu_name=$row[$_lang];
$menu_icon=$row["icon"];
...