I have 2 Django projects :
project_redirect, which is running on http://localhost.com:8005project_logged_in, which is running on http://localhost.com:8000 (I’m authenticated in this one)
When I try to do a redirect from project_redirect to a view that requires authentication in my project_logged_in, I get unlogged in project_logged_in (checked that with request.user.is_authenticated() in the first line of the view).
my redirect view is as sample as :
def test_redirect_view(request):
return HttpResponseRedirect('http://localhost.com:8000/login_required_view/')
Why would this happen?
Your session cookie is being shared by both projects as they are using the same domain.
Try setting
SESSION_COOKIE_NAMEin both projects to something unique.