The framework I would use is as follows:
-
each navigation session in your site (identified by a cookie or passing a parameter from page to page) constitutes a session-object. This is a standard technique and you may find helpful info with a little search. Sessions should have an expiration time.
-
each registered user has a profile and some data associated.
The user-object is created on registration and stored somewhere.
It doesn't expire (or does, but only after a long time).
-
when the session starts and you cannot determine if the user is known to the application, you start with a new "anonymous" user-object linked to the session.
You record the data in this user-object.
-
If the user logs-in, then his stored user-object is retrieved and his data and preferences are merged with those stored in the current anonymous user-object.
This way, if the user has selected a new 'preferred language' or has filled a form before logging-in, the info is not lost but kept for future use.
Hope that helps
Antonio
The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket