用户登录时如何将匿名会话数据合并或复制到用户数据中?
这是一个一般性问题,或者可能是对其他开源项目的指针的请求:
我想知道当用户登录时,人们如何将匿名用户的会话数据合并到经过身份验证的用户数据中。 例如,有人正在浏览您的网站,并将各种项目保存为收藏夹。他尚未登录,因此它们被保存到匿名用户的数据中。然后他登录,我们需要将所有这些数据合并到他们的(可能现有的)用户数据中。
对于不同的应用程序,这是否以特定的方式以不同的方式完成?或者人们可以指导我一些最佳实践或其他项目吗?
This is a general question, or perhaps a request for pointers to other open source projects to look at:
I'm wondering how people merge an anonymous user's session data into the authenticated user data when a user logs in. For example, someone is browsing around your websites saving various items as favourites. He's not logged in, so they're saved to an anonymous user's data. Then he logs in, and we need to merge all that data into their (possibly existing) user data.
Is this done different ways in an ad-hoc fashion for different applications? Or are there some best practices or other projects people can direct me to?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当然,这很大程度上取决于您的系统。但就我个人而言,我总是尝试合并数据并立即以与用户登录时存储相同的方式存储它。
因此,如果您将其存储在匿名用户的会话中以及任何经过身份验证的数据库中用户。登录后只需合并所有数据即可。
If very much depends on your system ofcourse. But personally I always try to merge the data and immediately store it in the same way as it would be stored as when the user would be logged in.
So if you store it in a session for an anonymous user and in the database for any authenticated user. Just merge all data as soon as you login.