[英]Storing shopping cart items into cookies and database
I am working on an e-commerce website. 我正在一个电子商务网站上。 When the user is not logged into my website and clicks on "Buy Now" button, I want to store this information into the cookie as well as in the database. 当用户未登录我的网站并单击“立即购买”按钮时,我想将此信息存储到cookie以及数据库中。 The table for the shopping cart looks like 购物车的表看起来像
SHOPPING_CART
(
sessionid int(10),
itemid int(10),
quantity tinyint(10) unsigned
date_added datetime
);
Primary key is: (sessionid, itemid)
主键是: (sessionid, itemid)
When the user closes the browser then also the shopping cart items should be preserved. 当用户关闭浏览器时,也应保留购物车项目。 Now my question is the following: 现在我的问题是:
IP address
? 我应该使用IP address
存储信息吗? If yes then HOW? 如果是,那怎么办? In this case sessionid
in the above mentioned table would be the IP address of the user. 在这种情况下,上述表格中的sessionid
将是用户的IP地址。 Right? 对? Note1 : I can use plenty of Shopping Cart softwares/codes/libraries available. 注意1 :我可以使用许多可用的购物车软件/代码/库。 But I want to know: How to identify the user? 但我想知道: 如何识别用户? And storing/retrieval of data. 以及存储/检索数据。
Note2 : The price of each item, ordering, shipping information all are stored in different tables. 注意2 :每个项目的价格,订购,运输信息都存储在不同的表中。
the only thing you have to do is set the sessionid into a client-cookie. 唯一要做的就是将sessionid设置为client-cookie。 if a customer returns and presents a sessionid cookie you update your cart table with his new sessionid (and set the new sessionid in the cookie). 如果客户返回并出示sessionid cookie,则您用他的新sessionid更新购物车表(并在cookie中设置新的sessionid)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.