Reputation: 17678
I'm currently working on developing a Symfony2 app that will not only accept user registrations, but will allow visitors to go through almost the entire flow of the site without creating an account or logging in. Design ideas look something like this (suggestions/improvements welcome):
USER_<session_id>
as an identifier instead of a personalized username. Any activity they perform on the site is persisted to this anonymous user entity What's the best way to go about this? Specifically, what is considered "best practice" for creating/manipulating a User entity for an anonymous user without having to place code into every controller?
Upvotes: 7
Views: 601
Reputation: 396
I would advise against using the IP address for this, as it could cause problems for users behind a NAT. Using a custom cookie, or the sessionId (PHPSESSID) cookie as an identifier for tracking purposes would be a better idea. Google uses this strategy for its ads business. Stand on the shoulders of giants!
Upvotes: 5
Reputation: 131
I have something similar to this that I've had to do. What I did was collected the anonymous users ip address (using ($_SERVER['REMOTE_ADDR'])). I then used the ip address for tracking purposes. You can then use that when they register to append their past usage to their newly created account.
You can then just run a simple query to drop any ip address that hasn't had activity in a while (most users have dymanic ip addresses so it will change every so often anyways).
Upvotes: 0