I am developing a Shopping Cart using PHP and stored the data in session. I plan to stored the data in session into database when the user logging out. So when they log in back, I can pull the Shopping Cart data from database.
But with this approach if the user has close browser without logged out and the session has expired, the data will lost without having stored in database.
Is there any way to handle the problem ? without having to directly stored to database each time user add an item to the Cart.