是否可以使用php在注销时将缓存的项目保存到db

User A log in and add items on cart. When he logs out, the items should be saved somewhere (database or where ever) so that when he logs back in from a different computer, he should see same items he left on his cart.

I think amazon website works like this.

How is this possible if I'm using php and the server is xampp? Or is it not possible?

Are you implementing this functionality in the core php? If it is in some framework or CMS than there will be some module or plugin for this.