Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django tracking anonymous users

Tags:

python

django

I am building a system which serves content on external properties. I would like to track users which have not registered with my site with anonymous unique IDs. Then, if later they register with my site, I can covert them to regular Django users, but still have information related to their preferences and activities when they were anonymous.

Is there a facility to automatically set a user cookie via Django so that if they user is accepting cookies, I have a user session ID to work with?

I'd prefer not to come up with a custom solution if Django has some path to move from Anonymous to Authenticated users.

like image 736
Jiyosub Avatar asked Jun 30 '11 02:06

Jiyosub


2 Answers

I suggest you look for sessions. They use cookies, store a unique id into a cookie which is linked to a file on your server containing their data.

https://docs.djangoproject.com/en/dev/topics/http/sessions/

like image 74
SBSTP Avatar answered Sep 22 '22 22:09

SBSTP


I've looked for a solution to problems like this in the past. Django Lazy Signup (https://github.com/danfairs/django-lazysignup) looks like it should solve your problem and not force you to reinvent the wheel, though, fair warning I haven't personally used the project.

like image 29
Adam Haney Avatar answered Sep 24 '22 22:09

Adam Haney