Answer the question
In order to leave comments, you need to log in
How to set cookie in js and pass cookie value to php code?
I'm trying to determine the city of the site visitor by ip.
1) The Yandex service determines the city and an inscription appears in the menu, for example: Your city: Ufa
2) You need to take the cookie value from js and display it in php code. The catch is that I'm just learning js and it's still not entirely clear to me how to transfer from js to php. I realized that you can get and fast. In this variant I try to transfer a getom. But the het is empty. How to write cookies to see them in <?php echo $_GET['cook']; ?>????
window.onload = function () {
jQuery("#user-city").text(ymaps.geolocation.city);
jQuery("#user-region").text(ymaps.geolocation.region);
jQuery("#user-country").text(ymaps.geolocation.country);
var city = ymaps.geolocation.city;
var cook = document.cookie = name + "=" + city; // write city to cookie
}
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