# django why cookie not sending to client browser?

**URL:** <https://forum.djangoproject.com/t/django-why-cookie-not-sending-to-client-browser/26225>\
**Category:** Deployment\
**Created:** [December 16, 2023, 6:03pm UTC](https://forum.djangoproject.com/t/django-why-cookie-not-sending-to-client-browser/26225 "2023-12-16T18:03:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MDFARHYN](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mdfarhyn/32/4519_2.png) [@MDFARHYN](https://forum.djangoproject.com/u/MDFARHYN)\
**Post date:** [December 16, 2023, 6:03pm UTC](https://forum.djangoproject.com/t/django-why-cookie-not-sending-to-client-browser/26225/1 "2023-12-16T18:03:59Z")

</div>

I properly setup cros. Trying to send cookie to client browser but don’t know where I am doing mistake and cookie not going to client browser:

setting.py

```auto
CORS_ALLOWED_ORIGINS = [
    "http://*",
    "https://*",]

CORS_ORIGIN_WHITELIST = [
    "http://*",
    "https://*",]

CSRF_TRUSTED_ORIGINS = [
        "http://*",
        "https://*",

CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_CREDENTIALS = True
SESSION_COOKIE_SECURE = True 

```

my api code:

```auto
from django.http import HttpResponse,JsonResponse

 @api_view(["POST","GET"])
 def UserProfileAPI(request):
 if request.method == "POST":
            #...others code performing validation if success then allow user login 
    login(request, user)
    #refresh = RefreshToken.for_user(user)
    #access_token = str(refresh.access_token)
    #refresh_token = str(refresh)

    serializers = AuthorProfileSerialzers(data=request.data)
   
    try:
        existing_profile= AuthorProfile.objects.get(author = request.user)
    except:
        existing_profile = None
    if not existing_profile:  
        if serializers.is_valid():
            instance = serializers.save()
            instance.author = request.user
            instance.author_pic = request.data.get("profile_image")
            instance.save()

    response = HttpResponse('Cookie set successfully')
    # Set a cookie named 'my_cookie' with a value 'cookie_value'
    response.set_cookie('my_cookie', 'cookie_value', max_age=3600, path='/',samesite=None,secure=False)
    return response 
   # return Response({"detail":"sucess","jwt_token":access_token,"refresh_token":refresh_token}, status=status.HTTP_200_OK)

     

```

I am receiving the 200 response from backend but don’t know why cookie isn’t sending to browser  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/f/b/fbb74a38b46885dc6fca105d933ab52ead0aa9f8.png)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 16, 2023, 7:55pm UTC](https://forum.djangoproject.com/t/django-why-cookie-not-sending-to-client-browser/26225/2 "2023-12-16T19:55:29Z")

</div>

Look at the “Cookies” tab (on the right side of that list - four over from “Preview”)

Or, look at the “Response Headers” in the “Headers” tab.

---

<div class="post-metadata">

**Author:** ![MDFARHYN](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mdfarhyn/32/4519_2.png) [@MDFARHYN](https://forum.djangoproject.com/u/MDFARHYN)\
**Post date:** [December 17, 2023, 5:45am UTC](https://forum.djangoproject.com/t/django-why-cookie-not-sending-to-client-browser/26225/3 "2023-12-17T05:45:20Z")

</div>

[KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell) Thanks for your comment.

here is screenshot of cookie tab. You can see it’s empty

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/d/1/d186987454f98f987f3e35a60e68113837215572.png)

here is Response Headers screenshot  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/3X/7/7/77bd364fc0d03f4a25069f7a8a2ec34767384b68.png)  
I can see cookie in my response header but why I am not seeing any cookie in my cookie tab? I also need to be set session id in my browser cookie.

---

<div class="post-metadata">

**Author:** ![MDFARHYN](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mdfarhyn/32/4519_2.png) [@MDFARHYN](https://forum.djangoproject.com/u/MDFARHYN)\
**Post date:** [December 17, 2023, 6:07am UTC](https://forum.djangoproject.com/t/django-why-cookie-not-sending-to-client-browser/26225/4 "2023-12-17T06:07:51Z")

</div>

[KenWhitesell](https://forum.djangoproject.com/t/django-why-cookie-not-sending-to-client-browser/26225/2) after investigate the issue I noticed I was missing `withCredentials:true` on my axois post request which was coming from my frontend.

---

<div class="post-metadata">

**Author:** ![MercyShark](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mercyshark/32/21238_2.png) [@MercyShark](https://forum.djangoproject.com/u/MercyShark)\
**Post date:** [May 12, 2024, 5:36am UTC](https://forum.djangoproject.com/t/django-why-cookie-not-sending-to-client-browser/26225/5 "2024-05-12T05:36:41Z")

</div>

but why the cookie is not shown in the browser ?
