IMO, you could use a cookie as a session driver too, but the cookies are limited to 4kb and you don't know how many items the user will add to the cart + cookies will travel with each request that is being performed on your site. So I would stick to the session.
Feb 13, 2022
5
Level 15
Session or Cookie
Hey Folks,
I have a shopping basket in my application, which I create by creating a UUID, and then storing it on the session, something like:
$request->session()->put('basket', $basketID);
I then store the basket ID in the database, so we can retrieve the items. This approach seems to be working fine.
I've pondered using cookies instead, but found testing them to be a royal pain. But I sort of feel like cookies would be a better option. Does anyone have any experience in this and could point to some pros or cons of the approaches?
Ta Andrew
Level 73
Please or to participate in this conversation.