There is a lot of confusion in REST because many people hear about the limitations of REST and consider them to be rules that apply for no reason other than following architecture as an end in itself.
The real question you should ask is why in REST there is a limit without limits, and what are the benefits you get from doing it. Keep in mind that REST is an architectural style designed for the long-term evolution of large-scale distributed systems. You simply wonβt have the problems that REST needs to solve in a small application where one database contains all your information.
A stateless restriction causes the property of visibility, reliability, and scalability. Visibility has been improved because the monitoring system should not go beyond just requesting data to determine the full nature of the request. Reliability improves because it facilitates the task of recovering partial failures. Scalability improves because the storage state between requests is not required, which allows the fast server component of free resources and further simplifies implementation, since the server does not need to control the use of resources between requests.
Thus, being a stateless person, a client request must have all the information necessary for its processing.
How important is visibility to you? Do you want to see the entire contents of the shopping cart with a customer request when you are debugging something, or is it good that you need to get this information from the databases?
How important is reliability? You have a large distributed system with several servers and databases, where is it important? If you have a large distributed system in which shopping cart information can be stored in different databases depending on the exact HTTP server that answered the request, if the server fails, only another server from this group will be able to fulfill the request and end the session , or a server from another group will force the client to restart the session. If all the information is contained in the request, then any server can do this.
How important is scalability? If you have a distributed system and you store information about a shopping cart in one database, it becomes a funnel for all your queries and you lose scalability. If you store it in several databases, you lose reliability, as described above.
So, do you have ambitious long-term goals, or will your application be big enough to run into problems that try to solve REST? If you always have several servers and one database, and you will use them for each individual request, it does not matter whether you become stateless or not. You can simply have the resource /shopping_cart or something like that, add material to it using POST requests and close or delete it when you are done.
If your data will be distributed across several databases, there are many HTTP servers responding to requests, cache servers, etc., and you want to be able to dynamically create capacity by setting up new servers as needed and removing them while reducing load, then go to full stateless and leave the basket with the customer.