I'm building a shopping cart,and have to store the product list that user has chosen before in SESSION. I wonder which kind of data is better in this situation ?
My question is :
Store the session data as an array. The $_SESSION superglobal is an array anyway so you'll be working with it natively. Not sure why you'd want to use JSON at all for something like this.
However, the third option that Leri mentioned is also a good idea. In the context of an e-commerce system, this will allow you to do better things in the future with the data - you can track uncompleted orders and make contextual recommendations etc.