How to use Javacript Variable in PHP Variable? I want to reuse the variable without posting. My code is below;
<!-- User Location -->
<script>
window.onload = function() {
var startPos;
var geoSuccess = function(position) {
startPos = position;
document.getElementById('startLat').innerHTML = startPos.coords.latitude;
document.getElementById('startLon').innerHTML = startPos.coords.longitude;
};
navigator.geolocation.getCurrentPosition(geoSuccess);
};
</script>
<div id='startLat'></div>
<div id='startLon'></div>
<?php
//Getting address from latitude and longitude
$latitude = $_COOKIE['startLat'];
$longitude = $_COOKIE['startLon'];
?>