# Django prefix for httpOnly cookie

**URL:** <https://forum.djangoproject.com/t/django-prefix-for-httponly-cookie/30730>\
**Category:** Getting Started\
**Created:** [May 1, 2024, 7:53pm UTC](https://forum.djangoproject.com/t/django-prefix-for-httponly-cookie/30730 "2024-05-01T19:53:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jigrain](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jigrain/32/20819_2.png) [@jigrain](https://forum.djangoproject.com/u/jigrain)\
**Post date:** [May 1, 2024, 7:53pm UTC](https://forum.djangoproject.com/t/django-prefix-for-httponly-cookie/30730/1 "2024-05-01T19:53:00Z")

</div>

I’m using rest framework with its add-on for easy jwt work:

```auto
SIMPLE_JWT = {
    "ACCESS_TOKEN_LIFETIME": timedelta(hours=1),
    "REFRESH_TOKEN_LIFETIME": timedelta(days=1),
    'ROTATE_REFRESH_TOKENS': False,
    "AUTH_HEADER_TYPES": ("JWT",),
    "ALGORITHM": "HS512",
    'AUTH_COOKIE': 'access_token', # Cookie name. Enables cookies if value is set.
    'AUTH_COOKIE_DOMAIN': None, # A string like "example.com", or None for standard domain cookie.
    'AUTH_COOKIE_SECURE': True, # Whether the auth cookies should be secure (https:// only).
    'AUTH_COOKIE_HTTP_ONLY': True, # Http only cookie flag.It's not fetch by javascript.
    'AUTH_COOKIE_PATH': '/', # The path of the auth cookie.
    'AUTH_COOKIE_SAMESITE': 'Lax', # Whether to set the flag restricting cookie leaks on cross-site requests.
}

```

А JWT token return to user from my login view:

```auto
    def post(self, request, format=None):
        data = request.data
        response = Response()
        username = data.get('username', None)
        password = data.get('password', None)
        user = authenticate(username=username, password=password)
        if user is not None:
            if user.is_active:
                data = get_tokens_for_user(user)
                response.set_cookie(
                    key=settings.SIMPLE_JWT['AUTH_COOKIE'],
                    value=data["access"],
                    expires=settings.SIMPLE_JWT['ACCESS_TOKEN_LIFETIME'],
                    secure=settings.SIMPLE_JWT['AUTH_COOKIE_SECURE'],
                    httponly=settings.SIMPLE_JWT['AUTH_COOKIE_HTTP_ONLY'],
                    samesite=settings.SIMPLE_JWT['AUTH_COOKIE_SAMESITE']
                )
                csrf.get_token(request)
                response.data = {"Success": "Login successfully", "data": data}

                return response
            else:
                return Response({"No active": "This account is not active!!"}, status=status.HTTP_404_NOT_FOUND)
        else:
            return Response({"Invalid": "Invalid username or password!!"}, status=status.HTTP_404_NOT_FOUND)

```

My main question is that on the server it is expected that the request body will have an Authorisation header with JWT prefix and token accordingly, httpOnly cookie can only be attached as a cookie to the request?

---

<div class="post-metadata">

**Author:** ![otomatikportal](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/otomatikportal/32/30385_2.png) [@otomatikportal](https://forum.djangoproject.com/u/otomatikportal)\
**Post date:** [October 23, 2025, 8:42am UTC](https://forum.djangoproject.com/t/django-prefix-for-httponly-cookie/30730/2 "2025-10-23T08:42:47Z")

</div>

There isnt any setting existing as  
‘AUTH\_COOKIE\_HTTP\_ONLY’: True  
in simplejwt package. You have been misguided by ai
