edit i am not getting the error undefined index ‘time’ any longer. Now i am not getting any errors, but when i try echoing $timezone; nothing happens.
what am i missing here that is causing the undefined index ‘time’? i do have jquery in the page.
index.php
<?php
session_start();
$timezone=$_SESSION['time'];
?>
script, using jquery to get the time and then setting it as a $_SESSION[‘time’] variable.
<script>
$(document).ready(function() {
if("<?php echo $timezone; ?>".length==0){
var visitortime = new Date();
var visitortimezone = "GMT " + -visitortime.getTimezoneOffset()/60;
$.ajax({
type: "GET",
url: "<?php echo $_SERVER['DOCUMENT_ROOT'].'/social_learning/php/timezone.php';?>",
data: 'time='+ visitortimezone,
success: function(){
location.reload();
}
});
}
});
</script>
timezone.php
<?php
session_start();
$_SESSION['time'] = $_GET['time'];
?>
just change
$timezone=$_SESSION['time'];to$timezone=isset($_SESSION['time'])?$_SESSION['time']:"";