[英]How to make a site “unique” from each user?
I have made a "dating app" website where you can like hard-coded users - just an assignment not implemented in real life:).我制作了一个“约会应用程序”网站,您可以在其中喜欢硬编码的用户 - 只是一个在现实生活中没有实现的任务:)。 Whenever a user logs in - which it only can if it has SignUp - and likes a hard-coded match it gets saved via local storage.
每当用户登录时——只有当它有注册时才能登录——并且喜欢硬编码的匹配,它会通过本地存储保存。 So whenever an other user logs in, that user has the exact same site and liked profiles.
因此,每当其他用户登录时,该用户就拥有完全相同的网站和喜欢的个人资料。 So my question is, how do you save a user action individually on a website - in theory - so not everyone share the same site.
所以我的问题是,你如何在网站上单独保存用户操作 - 理论上 - 所以不是每个人都共享同一个网站。 Links for articles would also be much appreciated, cause I investigated myself, but couldn't find any usefull articles.
文章的链接也将不胜感激,因为我调查了自己,但找不到任何有用的文章。
Thank you for your help in advance!提前谢谢你的帮助!
I'm assuming you don't have a backend and that is why you are using local storage.我假设您没有后端,这就是您使用本地存储的原因。
logalstorage is a set of (key, value) pairs. logalstorage 是一组(键,值)对。 You'll need to make the key unique depending on the user that is logged in.
您需要根据登录的用户使密钥唯一。
For example:例如:
let user = "Greg"
localStorage.setItem.(user + "likes", likes);
and to get the data later并稍后获取数据
let likes = localStorage.getItem.(user + "likes");
This idea of a unique key is exactly how databases work.这种唯一键的想法正是数据库的工作方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.