search

Home  >  Q&A  >  body text

How can a user add save to cart without logging in?

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中文网2752 days ago1009

reply all(5)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-17 10:07:11

    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,

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-17 10:07:11

    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.

    reply
    0
  • 黄舟

    黄舟2017-05-17 10:07:11

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

    reply
    0
  • 滿天的星座

    滿天的星座2017-05-17 10:07:11

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

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-17 10:07:11

    You can ask the user to cancel Disable cookies


    localstorage supports ie8, you can also consider it

    reply
    0
  • Cancelreply