I'm looking for any hints on recommended, or simply tried and tested, ways of associating data with an anonymous user in a web application. I want the data to be available to users across multiple sessions, so therefore store it in the database.
Obviously I will need some kind of cookie to identify that user, what I'm particularly interested in is how to manage the link between this anonymous identifier and the actual data. So far I am exploring two options:
- Creating a persisted anonymous user with each unique visitor. This way my data doesn't need to care whether it belongs to an anonymous user or registered one, it just belongs to a user.
- Have some kind of wrapper/manager for the data that uses its own unique cookie value to associate with the data.
The main issue with #1 is the number of users getting created. Running a script every 24 hours to clean the table out would be easy, but I could still be creating thousands (I hope!) of rows per day, keeping them for say 14 days would result in a lot. With #2 I have to build an anonymous/cookie-based infastructure thats specific to the data, but what happens when I have other sets of data that need the same functionality.
Does anyone have any best-practice advice on how this might be done? I'm working in ASP.NET MVC with NHibernate, but concepts and ideas fom any platform would be helpful.