I am working on a webshop, where the cart is stored in a session. I noticed that after a certain amount of distinct items added to the cart, I start receiving 502-responses, when I want to add more (distinct items). I am using Laravel and the site is hosted via Laravel Forge (using Nginx). I am using cookies to store the sessions.
.env
SESSION_DRIVER=cookie
I found lots of suggested solutions, but none of them worked for me.
I have meanwhile found the solution to this problem (see answer below). I am asking this question not because I need help, but because I want to help others who struggle with this issue, since it cost me a lot of time.
Asking questions just to answer them yourself is actively encouraged according to this blogpost by one of StackOverflow's co-founders: https://stackoverflow.blog/2011/07/01/its-ok-to-ask-and-answer-your-own-questions/.