Hi,
Seems like last time I was not that clear, so here is what I want to
do: I want to keep track of the users that visit my site, keeping in
the DB what IP addresses visited my site, when, ... I define a visit
as a click on one of my pages, given that this visit is done a certain
time after the last visit (30 minutes, 1 hour, 1day,... that can be
choosen).
I've decided to keep in the cookies, through the session middleware,
the value of the last visit. I do this with the request.session in the
process_view of a personal middleware I am trying to develop:
class IpMiddleware:
def _add_ip(this_ip):
# Adds IP and Visit to database
[...]
def process_view(self, request, view_func, view_args, view_kwargs):
last_visit=request.session.get('sysvortex_last_visit', datetime.now())
difference=datetime.now()-last_visit
if difference > timedelta(minutes=30):
self._add_ip(request.META['REMOTE_ADDR'])
return None
My problem is, I can not make the request.session to store my value.
No matter how many time I wait or what I do, 'difference' always is
(almost) 0. It seems to me that when I do
request.session.get('sysvortex_last_visit', datetime.now()) the value
is not actually saved, which seems strange.
I am struggling with this for a few days now, so any help or pointer
is higly appreciated, thanks!
G
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---