开发者

Saving user info without accounts

开发者 https://www.devze.com 2023-03-17 14:26 出处:网络
So, I have a website that figures out the users location when they load the page. They can change it if it\'s incorrect. I\'d like for the next time the user comes to the page, for it to remember what

So, I have a website that figures out the users location when they load the page. They can change it if it's incorrect. I'd like for the next time the user comes to the page, for it to remember what they changed it to the last time they were on.

We don't have user accounts on our website (and nor do we really want them right now). How els开发者_运维技巧e would I be able to link to and save this information based on the user logging on.

I could use their IP address (if it's blocked fine, don't need to do it for them). Is this not a good idea to just have a linked table setup with a pair of coordinates and an IP?

I was actually going to use the same logic to link a user to all their comments that they posted on the page to have a quick "My Comments" section, by linking it to their IP.

Without accounts, using a users IP address is really the only thing I can think of.


Given your requirements I'd say that saving the data to a cookie seems the simplest solution.

Response.Cookies["location"].Value = "0.008487,0.022724";

The users IP may have changed by the next time they visit your site, just as much as their cookies may have been cleared.

Also, you may find that users of your site will have the same IP address especially given that there's usually a single IP address on all shared routers. (Both in the home and in the workplace).

That may be something you've accounted for and wanted? But it means that one user changing their preference would also change the preference for all users of that same IP.

I think this method is fine for your location tracking service however for the comments and any other user preferences based work I'd start thinking about user accounts.

0

精彩评论

暂无评论...
验证码 换一张
取 消