Witam, chciałbym się zapytać czy ten kod jest poprawny, bo php nie wykrywa ciasteczka które powinno być ustawione przez ten skrypt.
var geo = navigator.geolocation;
if(geo) {
geo.getCurrentPosition(function(location) {
console.log('Szerokość ' + location.coords.latitude);
console.log('Długość ' + location.coords.longitude);
function setCookie(name, val, days) {
if (days) {
var data = new Date();
data.setTime(data.getTime() + (days * 24*60*60*1000));
var expires = "x:"+location.coords.latitude+"x:"+location.coords.longitude;
} else {
var expires = "";
}
document.cookie = name + "=" + val + expires + "; path=/";
}
});
}
else {
// niedostępna
}
</script>