带有用户购物车的电子商务项目
我想在线创建一个电子商务项目。我遇到这个问题:
如果用户未登录,则所选产品将自动添加到名为
guest001
、guest002
等的默认购物车中其中guestxxx
是默认用户。如果用户注册,那么系统将自动签入他的购物车数据并将其添加到他的新帐户
当用户想要将新产品添加到购物车时,它们将直接添加到他的购物车。
我的问题是:
我是否应该使用 cookie 将数据存储在用户的计算机中,以便用户创建帐户后系统会使用这些数据?或者我应该使用服务器端会话数据?
一旦未知用户将某些内容添加到购物车后,我是否应该在数据库中创建默认客户端(
guestxxx
),或者只创建一个 cookie 来存储数据,而不需要创建来宾用户?
I want to create an e-commerce project online. I have this issue :
if the user is not logged in, then the selected products will be automatically added to a default cart under the name of
guest001
,guest002
etc whereguestxxx
is a default user.if the user signs up, then the system will automatically check in his carts data to add it to his new account
when the user then wants to add new products to cart, they will be added directly to his cart.
My questions are :
Should I be using cookies to store the data in the user's machine, so it will be used by the system once the user creates his account? or should I use server side session data?
Should I be creating a default client (
guestxxx
) in the database once the unknown user adds something to his cart, or just create a cookie to store the data without the need to create a guest user?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我只是给你一点小建议。
如果您使用的是 Codeigniter Framework,则可以使用 Library Cart Class
或者你想自己编写代码。
根据我的经验。当用户结账时,我将其购物车添加到我的数据库中,我使用了商店购物车的会话。
在浏览器关闭时使用它的缺点,您的访客购物车将从默认状态开始(无购物车),
如果您在浏览器关闭时使用 cookie,您的访客购物车将保持存在。 (存储在浏览器中)。但我认为你可以同时使用它。在 PHP 代码中使用 cookie 保存购物车数据并使用会话处理购物车。由于Cookie存储在浏览器中,恶意用户可以对其进行恶意活动。
对于客户,我认为你可以使用会话或cookie,而不是将他的数据添加到数据库中
希望它可以帮助你。我只是对此了解甚少。
I just have little suggestion for you.
If you are using Codeigniter Framework you can use Library Cart Class
or you want make code yourself.
According to my experience. I was used session for store cart while users checkout I add his cart into my database.
Disadvantage of using it while browser is closed your guest cart will start from default (no cart),
If you use cookie for it while browser is closed your guest cart will keep exist. ( store in browser ). But I think you can use both of it. Use cookie for keep cart data and use session for processing cart in your PHP Code. because Cookie is stored in browser, malicious user can do malicious activity of it.
For client i think you can use session or cookie rather than add his data into database
Hope it can help you. I just know little about it.