I think the best approach is: do not re-invent the wheel
ASP.Net contains something called: User Profiles
They work by storing user preferences and they work for both, anonymous and authenticated users.
When a user is anonymous, his profile is stored in cookies. When the user becomes authenticated, you can migrate the existing anonymous profile to store it in the database.
ASP.Net contains functionality to do all this job for you. You can even access the profile properties using JavaScript
I already answer a couple of questions that can explain the process:
How to persist anon user selection (ex: theme selection)
accessing profile.newproperty in MVC web applications
Note: If you are using a Web Application instead of a Website, then the answer provided in the first link won't work, that's because the Profile
class is pre-compiled only when using a Website. In order to implement the profiles functionality, you should create a custom class and inherit from ProfileBase
. You can use the code specified in the second link, even when that example is made specifically for MVC, the profile class, and the profile registration in the web.config are the same for any Web Application