Multidimensional array in cookie in express?

EDIT: I think I figured out what I was doing wrong!

old post->

So I’m trying to learn node, using a working to-do list that stores user data in a cookie as the basis and trying to expand that to a grocery list with separate categories.

The desired output will look similar to this, with a form at the bottom with a select element with options to route the types of items to their respective areas.

My intent is to do that with JS, changing the formAction depending on what option is chosen (ie, fresh, grocery, beer-and-wine, other), and send that to routes like “/list/fresh/add/” or “/list/grocery/add”.

Now the problem is… I can’t figure out how to separate the cookie. Is this possible? I am trying to use it as a multidimensional array-- req.session.shoppinglist[0] will be fresh, req.session.shoppinglist[1] will be grocery, etc. However, I get an error whenever I try to push to one of the new arrays or foreach it in the template file. I know it’s not the syntax because I tested it all out on a browser console.

As far as subdividing the cookie in the first place, I tried two methods:
declaring it as req.session.shoppinglist = [ , , , ], as req.session.shoppinglist = [ new Array(), new Array() …], and finally just pushing new arrays in… req.session.shoppinglist.push( new Array() ); Not sure but I got an error when I tried to put anything in the array(s).