I played around with this a bit more and found that when we call
set_test_cookie, no cookie by the name of 'testcookie' is set on your
local box. If you look at the
code it is supposed to set a 'testcookie' with the value of 'worked'.

Since it did not work as expected, I worked around this by checking
the request.COOKIES for the 'sessionid' cookie before every request.
This ensures that even if a user turns off cookie support in the
middle of browsing, the broser will detect it.

jim




On Nov 27, 11:25 am, jim <[EMAIL PROTECTED]> wrote:
> In order to test if the browser has cookie support, do we have to
> place this cookie test on every function? Is this the general
> practice? I mean what happens if a person has cookie support turned on
> and while browsing he/she turns it off?
>
> Also, If we use aset_test_cookieon the GET request and a
> test_cookie_worked on the POST request, if the user hits the 'BACK'
> button on POST page, the browser picks the page from it's cache,
> thereby not executing the  set_test_cookiefunction. So when the user
> POST a second time, if will throw an error that the test_cookie_worked
> failed. e.g
>
> if request.method == 'GET':
>         request.session.set_test_cookie()
>         return render_to_response('register.html',
> RequestContext(request, {}))
>
> elif request.method == 'POST':
>
>         if request.session.test_cookie_worked():
>            request.session.delete_test_cookie()
>         else:
>            return render_to_response('register.html',
> RequestContext(request, {'cookie_error':'We have detected that your
> browser does not support cookies. This site requires cookies for
> proper functioning. '}))
>
>        ....
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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