Answer the question
In order to leave comments, you need to log in
Am I using the $_SESSION variable correctly?
I can't figure out where I'm doing wrong.
In general: the site is managed by 1s Bitrix.
using sxgeo I determine the city of the visitor. It works. here is the calling code.
<?
print_r($_SESSION["city"]."work") ;
if(!$_SESSION["city"]){
include("SxGeo.php");
$SxGeo = new SxGeo('SxGeo.dat');
$ip=$_SERVER['REMOTE_ADDR'];
$city = $SxGeo->getCity($ip);
$_SESSION["city"] = $rucity = $city['city']['name_ru'];
echo "
<div class='alert'>
ваш город ".$rucity."
</div>
";
}
?>
function cityselected(){
city = $('.cityselect').val();
alert(city);
$.ajax({
type: "POST",
url: "/some.php",
data: "city="+city+"",
success: function(msg){
alert( "Data Saved: " + msg );
}
})
window.location.reload();
}
<?
unset ($_SESSION['city']);
$_SESSION["city"] = $_POST['city'];
echo "выбран город: ".$_SESSION["city"];
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question