E-commerce project with users cart
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开发者_Go百科 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?
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.
精彩评论