根据位置选择着陆页重定向(Cookies?)[关闭]

Before someone gets upset that I haven't included code, please understand that it is because I am not sure what the best practice would be.

I have a site that operates in 3 cities specifically, and also a nation-wide version. This is an eCommerce site that has different subdomains (essentially 3 different sites, but the ability to manage products specifically based on location.)

What I need is for the user to select their city or location preference (say New York, Chicago, Detroit or Entire US) and have that information stored so that the next time they return they don't have to reselect their preferred location.

Of course, for UX purposes the ability to change location is available in a Top Nav menu bar should they temporarily be in the other city.

Can IPs be targeted accurately to exact city? Should this be automated or should they be able to choose?

My question is : What is the best practice for this? Are there any consequences to this setup? What should be used? JavaScript? JQuery? PHP?

If there are no major negatives, where should I start to implement this?

IP's technically COULD be used to track general location but are not always reliable and would require a third party service to resolve. This would create overhead and could introduce other problems. In my opinion a better option would be to ask the users location at register and allow them to change it from the UI like you said. You could use only non expiring cookies, but when a user clears cache they will need to reset. I recommend saving this location feature to the users table in DB... and also in the users session at login. This makes for a better, more reliable, and smoother UX.