Anas
Anas

Reputation: 1861

Getting unlogged after a redirect in django

I have 2 Django projects :

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?

Upvotes: 0

Views: 90

Answers (1)

Iain Shelvington
Iain Shelvington

Reputation: 32294

Your session cookie is being shared by both projects as they are using the same domain.

Try setting SESSION_COOKIE_NAME in both projects to something unique.

Upvotes: 1

Related Questions