非注册用户的购物车 [英] shopping cart for non registered users

查看:72
本文介绍了非注册用户的购物车的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个涉及购物车的网站. 有两个主要要求:

I am in the process of making a website that involves a shopping cart. There are two major requirements:

  1. 用户体验专家希望登录/身份验证是整个工作流程中的最后一步.用户可以进行所有购物,并且仅在结帐时才被要求登录.

  1. The user experience guys want login/authentication to be the very last step in the entire work flow. The user gets to do all the shopping and is asked to login only at the time of checking out.

购物车不应过期(即使在浏览器关闭时也不应该过期),除非用户(无论是否注册)都进行了结帐.

The shopping cart shouldn't expire(not even on browser close) unless the user (registered or not) does check-out.

在上述情况下,关于维护购物车的状态,我有以下问题:

In the above context, I have the following question with respect to maintaining the cart's state:

我应该使用基于文件的会话还是数据库会话?请记住,这将适用于未注册的用户.我的担心是,我最终将在数据库中拥有很多记录.

Should I go with file based or database sessions? Please keep in mind this would be for unregistered users. My apprehension is that I'll end up having lots of records in the database.

另一个选择似乎是将购物车中的内容放入加密的cookie中,但是cookie文件有大小限制.

Another option seems to be to put the cart contents in an encrypted cookie, but then there's a size limitation on the cookie file.

在这种情况下,您会怎么做?非常感谢您的回答.

What would you do in this case ? I would really appreciate your answers.

推荐答案

  1. 跟踪用户.使用GUID 使用 n 年满.

  1. Tracking a user. Use a GUID encoded into a cookie with an nYear expiry.

存放购物袋.您不希望将袋子存储在cookie中,这主要是因为它的大小.这样就可以选择将其驻留到介质中,然后从介质中检索它.使用除数据库以外的任何工具都将像是时光倒流,数据库擅长存储和检索数据.

Storing a Shopping Bag. You don't want to store the bag in the cookie, mainly due its possible size. This leaves the option of persiting it to a medium and retrieving it from the medium. Using anything except a database for this would be like going back in time, databases excel at storing and retrieving data.

管理您的购物袋.现在 您的架构问题,首先,如果 您将要运行的查询 反对在购物袋 数据库(即购物次数 袋子中包含物品 x ),您可能 想要传统的关系 模式.但是,这有开销 在插入方面.更新, 选择(并加入)并删除 行李数据(在某个时候,您将拥有 不再使用的袋子 但正在占用宝贵的磁盘 空间).在繁忙的网站上,这是一个 每秒很少的事务数量, 但是任何数据库都应该能够 应付.如果您不需要查询 数据库中的购物袋, 然后您可以将其存储为XML.只是 序列化袋子并将其倾倒到一个 表,以PK作为GUID 存储在用户cookie中.这 会比 传统模式,加上您可以 总是将XML拆开 将来是否有要求 关系模式.

Managing you Shopping Bag. Now, the question of your schema, firstly, if your going to be running queries against the shopping bags in the database (i.e. how many shopping bags contain item x) you probably want a traditional relational schema. However this has overheads in terms of inserting. updating, selecting (and joining) and deleting bag data (at some point you'll have bags that will never be used again but are taking up precious disk space). With a busy site, this is a fair few Traranactions Per Second, but any database should be able to cope. If you don't need to query the shopping bags in the database, then you can store it as XML. Just serialize the bag and dump it into a table, with the PK as the GUID as stored in the users cookie. This would be a lot faster than a traditional schema, plus you could always tear apart the XML in the future if a requirment did come up for a relational schema.

这就是我们的工作(Xml Bag),我们拥有超过一百万的客户群.

This is what we do (Xml Bag), and we have a million+ customer base.

这篇关于非注册用户的购物车的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆