I am working on a geolocation project that is browser-based and geared specifically towards mobile browsers. I won’t go deep into details but overall the project uses geolocation across many pages and pieces of the project. The problem as it seems is that despite hitting “accept” and “allow” always on any given browser, when the user reloads a page they are prompted almost everytime to reallow the location authentication.
Which to me is weird, I’ve gone to sites with geolocation on it that it truly remembers that I allowed it, even if for the duration of me being on the site and not always. So with that I am wondering is there some type of special thing I need to do to store this authentication for a prolonged period on my project?
Currently I am using javascript-based geolocation through the google maps API and newer browser support for non ip based location. My project at the users discretion tracks where they are so other people connected to them can see where they are, where they have been, or where they plan to go (if they enter that in). There’s more as well, but that’s the basics. From a UX perspective, it’s annoying to have to prompt my users every time the browser reloads to reauth the location.
So any advice anyone is able to give, or insight on how to handle this would be appreciated.
Cookies and sessions.
Right after detecting the user geo-location you should store it in a Cookie.
Every request from the server should look if there is a cookie set (with the user’s location) and act upon it.
Over-simplified code:
Then on the server you grab the
initialLocationand save it in a cookie.