Last active
July 29, 2022 05:28
-
-
Save kaspereden/5d4528cc3c8f304cb009 to your computer and use it in GitHub Desktop.
Store geolocation in cookie
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
In order to store the object we 'flatten' the object. This has strange results in the latest version of Safari (8) | |
*/ | |
navigator.geolocation.getCurrentPosition(function (geolocation) { | |
// in order to store the location in a cookie we 'flatten' the object to json | |
var cookieValue = JSON.stringify(geolocation); | |
}); | |
// On chrome the cookieValue contains the JSON string | |
'{"timestamp":1414403164942,"coords":{"speed":null,"heading":null,"altitudeAccuracy":null,"accuracy":30,"altitude":null,"longitude":4.3267961,"latitude":52.096922799999994}}' | |
// On safari 8 the object is an empty JSON string | |
'{}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello! How to get information about what sites the user has visited?