How can a user add save to cart without logging in?
PHP中文网
PHP中文网 2017-05-17 10:05:11
0
5
1046

In such cases:

Some users find it troublesome and require that they add the purchased goods to the shopping cart without logging in. When logging in, they add the items added when not logged in to the shopping cart.


The method I currently know is to use "Cookie" to save the product ID locally to the user, read it out when logging in, and update it to the user's shopping cart. But consider that some browsers disable cookies.

Is there any other way?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(5)
伊谢尔伦

For modern browsers, it is recommended to use localstorage to replace cookies. The benefits are not described.
If you want to be compatible with old browsers, you can only use cookies. When the user adds items to the shopping cart, check whether cookies have been disabled. If disabled, the user will be prompted. Just guide the user to enable it, but this situation is rare. It is recommended that you write a storage object similar to the cookie|localstorage adapter yourself,

Peter_Zhu

Prompt the user to turn it on, otherwise the function cannot be used.

What should I do if the user disables JS? What should I do if the user is still using IE6? Some users just give up.

黄舟

You can consider trying LocalStorage. You can go to MDN to learn more about it

滿天的星座

It is stored in localstorage. Create an object to specifically store it

巴扎黑

You can ask the user to cancel Disable cookies


localstorage supports ie8, you can also consider it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template