ShoppingCart with Session

I’m trying to create an eCommerce project just for learning. Actually I have my catalog with products but I’m not sure about how to make the Cart, I have an index with a dataprovider _post for each product with its button addToCart and I want to save the product id in a session to fill thes Cart, but where I should open the session? In the CartController in each Action? I’m a little bit lost about how to manage or get this data.
Thank you so much!