AP257
AP257

Reputation: 93793

Django: check cookie on every page?

In Django: what's the best way to check whether a cookie is set before loading every page?

Background: I'm working with a site that uses LDAP auth. I want to avoid having to ask forrequest.META.get('REMOTE_USER') on every single page, because it absolutely hammers the server: it's requested for every resource on the page, the server gets tied up, falls back to Basic auth and the user sees lots of dialogs.

Therefore, I would like to do the following on every page in the site:

Basically, I want an approximation of the @login_required decorator, without actually using the Django login/user framework.

Any suggestions for the nicest way to do this for all pages in the site, without repeating lots of code?

many thanks!

Upvotes: 0

Views: 1485

Answers (1)

Related Questions