I am still having trouble with Safari and cookies. I can login only
sometimes with Safari. About half the time I receive an error page.

There is a login box on all the pages of my site. Since I need to set
a test cookie before users login, I have the following code in a class
that is in the base class that is instantiated each request.

# AnonymousUser tracking placeholder.
if not self.request.session.get('online') and not
self.request.session.test_cookie_worked():
    self.request.session.set_test_cookie()
else:
    if self.request.session.test_cookie_worked():
        self.request.session.delete_test_cookie()
        self.request.session['online'] = True
# request.user.is_authenticated()
if self.request.user.is_authenticated():
    if not DEBUG:
        self.request.session.set_expiry(7200)

The following is my login view.

class LoginView(Base):
    def __init__(self, *args, **kwargs):
        if hasattr(Base, '__init__'):
            Base.__init__(self, *args, **kwargs)

    def POST(self):
        if self.request.session.get('online'):
            user = authenticate(username=self.request.POST.get
('username'),
                                password=self.request.POST.get
('password')
                                )
            if user is not None:
                if user.is_active:
                    login(self.request, user)
                    self.set_status_code_302('/community/%s/' %
user.username)
            else:
                if hasattr(self.resource.site, 'private'):
                    if self.resource.site.private:
                        self.status_code = 403
                    else:
                        self.set_status_code_302('/community/
register/')
                else:
                    self.set_status_code_302('/community/register/')
        else:
            self.status_code = 500
            self.status[500]['error'] = u"You must enable cookies in
your web browser."

The error I receive about 50% of the time with Safari is set during
the last line of the LoginView class.

What might be the problem? Suggestions are appreciated.

Luis.
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to