You should read these resources. They are not the most basic manual, but have some references that may be useful. Of course, I assume that you have read basic information an manuals about sitemaps.
Sitemaps are references for crawlers about what pages you want to get indexed. Of course they may, and will, discover more pages on your site than the ones on your sitemap if it is not exhaustive. So, if you want to make the process of getting the whole site indexed easier, include every single page on it.
Pages with query parameters determine which content is going to be shown, so they also should be on the sitemap. If you have content that may appear with more than one URL, you can use the canonical attribute to tell Google which page/URL is the important of the set. But even if you don't do that, they will aggregate all the duplicates on the same group and show only one in results; even if all the possibilities are crawled and indexed.
Pages that depend on cookies, shouldn't be on the sitemap, but the originator of the process should be, so using your example of the cart, you should include this:
but not these:
Some people may argue that even the cart itself shouldn't be, but some people consider it also a page and they have some default content on it so they want it indexed. I wouldn't include it.