I have a User
class in my web app that represents a user currently logged in.
Every time a user vists a page, a User
instance is populated based on authentication data supplied in cookies.
A User
instance is created even if an anonymous user logs in - and a corresponding new record is created in the User
table in the database.
This approach allows me to save some state info for the current user regardless of its type.
The problem however with this approach is the Google bot, and other non-human web organisms crawling my pages. Every time a bot starts to walk around the site, thousands of useless records will be created in the database, each of them only to be used for a single page.
Question: what is the best trade off? How to support anonymous users, save their state, and don't get too much overhead because of cookieless bots?