khurram,
You can go at it one of two ways.
1. Cookies w/ Database
2. Login w/ Database
I would rather go with the first. But if they do not have cookies enabled, then it want work. Lets say that once they enter the site, they are automatically assigned a URLTOKEN correct, now once they click add to cart, it automatically adds that item to the database in reference to the cookie ID. It's not hard, but the thing is, you have to design you database with every possibility.
Happy Programmer
Grover Fields