Skip to content

Instantly share code, notes, and snippets.

@kaspereden
Last active July 29, 2022 05:28
Show Gist options
  • Save kaspereden/5d4528cc3c8f304cb009 to your computer and use it in GitHub Desktop.
Save kaspereden/5d4528cc3c8f304cb009 to your computer and use it in GitHub Desktop.
Store geolocation in cookie
/*
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
'{}'
@FarzonaEraj
Copy link

Hello! How to get information about what sites the user has visited?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment