Support the ongoing development of Laravel.io →
Security Session Database

I have a shopping cart ID that I'd like to save somewhere to pick up the cart later when the user comes back. Should I put it in the session or better in a cookie? (Session config 'lifetime' => 43200)

Or in other words is there any issue if my session lifetime is very long?

Last updated 3 years ago.
0

I'd say it depends how you want to save the data.

If you want them to be able to come back the next day with their cart still filled use a cookie, else a session would be wise. Keep in mind that if you decide you go for a cookie that a shared computer remembers the data so others would be able to see what's in the cart if they visit the website too.

I myself would recommend a session in this case.

I don't know much about the actual data transfer for sessions and am unsure if it would be wise to have such lenght on a session.

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

futureFry futurefry Joined 4 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.