在没有登录asp.net的情况下,确定用户在线购物

编程入门 行业动态 更新时间:2024-10-10 03:27:21
本文介绍了在没有登录asp的情况下,确定用户在线购物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

先生,请尽快给我回答

推荐答案

您可以执行以下操作: 未经身份验证的用户将第一个项目添加到他的购物车中,为其分配一个唯一ID。 将该ID存储在cookie中 在数据库中保存对购物车所做的更改,使用该ID作为主键。 当会话超时时: 从cookie中读取先前分配给用户购物车的值 从存储在数据库中的数据恢复当前会话的购物车。 有一个缺点: 假设您已将用户的购物车存储在数据库中,并且用户永远不会回来。在这种情况下,您将要实施清理策略,例如,购物车最多存储两周。 当用户清理浏览器的缓存时也会发生这种情况 考虑到用户可以使用不同的浏览器浏览您的网站(因此,不同的缓存/ cookie) You can do the following: When an unauthenticated user adds the first item to his cart, assign it an unique id. Store that id in a cookie Save in your database the change made to the cart, using that id as a primary key. When the session times out: Read from the cookie the value previously assigned to the user's cart Restore the cart for the current session from the data stored in the database. There is a downside: Suppose you have stored an user's cart in a db, and the user never comes back. In this case you'll want to implement a cleanup policy, say, cart are stored for two weeks max. This can happen also when the user clean his browser's cache Take into account that a user can browse your site with different browsers (and thus, different caches/cookies)

您好, Cookie [ ^ ]将是一个选项。 从用户处获取电子邮件ID并将其保存在cookie中。 (非常常见) 每次匿名请求到服务器时都要检查该请求是否包含任何cookie。 如果没有,则创建一个Guid(或可以创建您自己的唯一ID)并通过将cookie添加到您的回复中以加密格式发送。如果您的请求有cookie,请检查值是否合适。 Hi, Cookie [^]would be a option for you. Take email id from user and save it in cookie. ( very common ) Each time anonymous request comes to server check whether that request contains any cookie or not. if not then create a Guid (or may create your own unique id) and send it in encrypted format by adding that cookie to your response. If your request have a cookie then check the value is proper or not.

更多推荐

在没有登录asp.net的情况下,确定用户在线购物

本文发布于:2023-11-07 15:45:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566853.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:情况下   在线购物   用户   asp   net

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!