Search code examples
djangodjango-sessionsdjango-context

session variable or extra context?


I need to have a few variables accessible on almost every view. I think I can see how to do it either using a context processor and "extra context" values, or by using session variables. Are there advantages and disadvantages? Which approach should I use? Are there meaningful differences? I see that to access session variables in a template, I have to enable django.core.context_processors.request


Solution

  • Sessions is a good way to store variables for that you can use on other pages in your website. Nothing wrong with using sessions.