There is a problem with using only a session, which is default that takes very little time ( in general the lifetime of a session is 24mins ), I can put it in the cart now, I'll talk / ask my girlfriend / mother / father ... and in a hour or two already there is not, in this scenario is "bad" because there is very little leeway (time) for the user to keep the "candidate" products to be bought. In this case the ideal would be to strengthen with cookies (your way is also correct, in the database and after 3 days these are eliminated), or if you can, change the lifetime of the session as the colleague @TTKDroid mentions in his response (although this consumes resources on the server).
That said, then:
In reality it depends on your needs, there is no rule for this, if you want to permanently save what users thought but did not buy, you should insert in the database if you want it to be only temporary you can only leave in session / cookies.
I believe that many systems, especially big , permanently store this data for future functionalities (eg algorithms to know the interests and show results according to the categories of products that have already been in your cart and / or that you have already bought) or simply for statistics, as colleague @Daniel Omine said can also help in strategic sales decisions.
It all depends on whether you think it's worth it, you have support for it, and for what purposes you'll keep it permanently.
Personally, it has been very rare to create a system in which to store the cart information in the database, simply because for most online stores this information would be wasted, that is, it would be data that would have no objective in the future and would only take up space on the disk, so it's not worth saving.
Thinking / weighing this decision is always in the hands of system programmers / owners / owners.