Persisting a shopping cart in Ruby on Rails

前端 未结 2 1591
暗喜
暗喜 2021-02-15 17:03

Currently developing a shopping cart, the options for persisting the cart, as i see them are:

  1. Store the entire cart object in a sessions table.
  2. Store the
2条回答
  •  余生分开走
    2021-02-15 17:28

    #3 is probably your best bet, because that gives you the most freedom/flexibility. Say someday you want users to be able to save their shopping carts between sessions. Or you want to keep shopping cart histories for your users. Or you decide to run some analytics on shopping cart data.

    #2 is a bad solution because of the cookie size limits on browsers. You're setting yourself up for nasty bugs where large shopping carts get corrupted, particularly in older browsers.

提交回复
热议问题