I might be wrong, but I am not aware that any shopping cart is user related, unless you are providing the ability to save and restore a cart against a user profile.
The cart contents are normally stored for the length of the session / cookie (depending on what method you are using), but I'm not aware the carts are ever user specific.
If you want to achieve this you would need to personalise the 'logout' script to save current cart contents and then empty basket. Then on log in your script would need to check for a saved cart and then repopulate.
Cheers
Ian