0

I am not a Django nor a Python programmer (I do know Perl, PHP, and Javascript pretty well though). I was given a Django site to work on and I understand the templating really well, I just never touch any actual Python code. My client wants a log-in on every page of the site, which is easy to do… but often when a user logs in, they get the error message "Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in." I guess that's because a test cookie is set when you go to the Django log-in page, and then when you log in, it checks for it. If you're not logging in from the log-in page/don't have the cookie set, you get the error. I tried a hack to load the login page in the background via AJAX to set the cookie and that for some reason only works about 50% of the time. Are there any Django/Python experts out there who can tell me step-by-step what a non-hack way would be to prevent this error from coming up?

Community
  • 1
  • 1
Dan Goodspeed
  • 3,484
  • 4
  • 26
  • 35

1 Answers1

0

Check this question for how to use Django to set persistent cookies.

Also check this question for how to get cookies.

I think the solution you need is the combination of both; create a test cookie under any name, set it, and then check to see if it exists prior to generating your view.

Community
  • 1
  • 1
FrobberOfBits
  • 17,634
  • 4
  • 52
  • 86
  • Those just give Python code but don't tell me where to put it. I'm not a Python/Django developer so those don't help at all. – Dan Goodspeed May 05 '14 at 21:52
  • You would put this code into your view, which would be in the views directory. With all due respect though if you don't know anything about Python it's going to be hard to get what you need. We can't tell you where to put things without you posting all of your code. Also, this forum is meant to help people help themselves, not to do it for them. You either need to learn enough to take advantage of the answers you're given, or ask someone else to do it. There's nothing wrong with not knowing python, but if you want to solve this problem you have to learn some. – FrobberOfBits May 06 '14 at 12:00