Here is a short description of the website I am working on:
Public pages can be accessed via HTTP or HTTPS indifferently.
Some other pages (authentication page, account details page, etc) require to be accessed by HTTPS. Apache2 takes care of making the relevant HTTP to HTTPS link redirections.
I use the standard Django authentication system with
'django.contrib.sessions'
added to theINSTALLED_APPS
insettings.py
.Following recommendations in the Django doc, I have set
SESSION_COOKIE_SECURE
toTrue
insettings.py
.On all pages, I display on the top a little box that either displays a link to login (if the user is not authenticated), or a link to the account page saying "Welcome, [Your Name]".
My problem is the following: If a user authenticates and goes later to a public page by using an HTTP link, the session cookie will not be transmitted to the server (because SESSION_COOKIE_SECURE = True
). That will cause the box on the top of the page to display a login link rather than "Welcome, [Your Name]".
How can I display the "Welcome, [Your Name]" on public pages for authenticated users, even if they use HTTP? Of course, I would like to keep the access to the sensitive pages safe, and I should therefore keep SESSION_COOKIE_SECURE = True
to avoid possible stealing of the session token.