本文介绍了在没有登录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的情况下,确定用户在线购物
发布评论