0

Can an object be stored as a cookie in JSF? If so, does said object and its attributes need to be serializable?

For example, say shopping cart in an online store wants to use an ArrayList<StoreItem> and save the array and the StoreItem in a single cookie.

Example:

ArrayList<StoreItem> cart = new ArrayList<StoreItem>;

    //StoreItems added to list

    FacesContext.getCurrentInstance()
      .getExternalContext()
      .addResponseCookie("cart", cart, null);
Isaac
  • 35
  • 1
  • 9
  • I don't think that's possible.. you should store card ID and then look it up – damian Apr 09 '14 at 19:00
  • In theory Yes, if you convert your array in String: `javax.servlet.http.Cookie.Cookie(String arg0, String arg1)`. But I agree with Damian, store ID and reuse it. See [this answer](http://stackoverflow.com/questions/20934016/how-to-add-cookie-in-jsf/20935305#20935305) as inspiration. – Vasil Lukach Apr 09 '14 at 21:13

0 Answers0