For cookie based authentication, my server sends Set-Cookie to my Angular application. However, the application doesn’t send the value back in further requests. Following is my code.
The server sends the cookie as follows in 200OK of my code (not shown here)
The next message however hasn’t got the id in the cookie, thus the server returns 401. If I manually add the Cookie using browser’s debug tools, then I get 200OK. Thus I am certain it is the absence of the id value in the cookie which is causing the issue.
What am I doing wrong? Do I need to explicitly store the cookie received in Set-Cookie and explicitly add it in further requests?
Update — At the time when the SPA is initially loaded, the server sends Set-Cookie header with some other cookie’s information related to CSRF . I notice that that cookie is still sent by the application. Could it be that Angular honors the first Set-Cookie header but ignores the subsequent ones?
I have added couple of pics to explain what I mean
During signing, the client sends a cookie related to CSRF. I dont think it is required as the client also sends CSRF Header but for some reason it does. The server responds with Set-Cookie with id in it

Then when I ask for profile, the client again sends the CSRF cookie but not the id cookie


1 Answer 1
Finally I was able to find the issue. The journey was more satisfying than the result so let me break it down into the steps I took to solve my problem.
In summary, This wansn’t an issue with Angular. The cookie I was sending had secureCookie flag on. As I was testing my application without https , it seems that the angular application was not using (or getting access to) the Set-Cookie header received in 200 OK .
My initial code to send the sign in request to the server and handling its response was
I wasn’t using observe: ‘response’ option which meant that the response would only contain body, not headers. I changed the code to following so that I could see which headers are being received.
The above code was being called as follows. I change that to get the headers in the response
I also created an intercepter to print the incoming and outgoing messages (copied from SO)
When I started debugging, I noticed that though the server was sending 10 headers, only 9 were getting printed
headers from server

Print message on console ( Set-Cookie was missing! The header my application needed to get authentication cookie)
This gave me a direction that the application is not seeing Set-Cookie header. I thought I’ll be able to resolve it by adding CORS policy in play framework exposedHeaders = [«Set-Cookie»] but that didnt work. Later I looked closer at the cookie and noticed secureCookie setting
This made me think that maybe my cookie settings are wrong for my environment (localhost, no HTTPS). I changed the cookie settings in Silhoutte
Though I’ll make the above code work for secureCookie and this wasn’t an issue with Angular, I hope that some folks might find the approach helpful
Comments
Copy link Quote reply
amankapoor commented Oct 31, 2017
This is my config file.
My app server is on port 8080 and I have not set up any end point there to receive any info from your server on 4180. (I actually don’t even know if I have to do something like that because I can’t move forward with this named cookie not set error).
I copied your sample config file, read some similar issues here and trying tweaking my config to make it work. But it is not working, and here are the logs.
I was looking for an easy plug n play solution for authentication basically and came across this. But I am unable to make it work, can you please help?
Btw, do you see in the logs that it show secure-cookie to be true even when I have deleted that from the config file?
Sponsored Links
About this tutorial must read:
Required for Karbonn A9 Boot repair:
- Karbonn A9 Boot repair full source file
- Karbonn A9 with full battery charged
- Micro USBcable
- Computer or Laptop
Procedure:
- First download all files are required
- Extract QPST-2.7.399 zip file
- Open QPST-2.7.399 folder
- Click on » Setup » button (see below image tutorial)
- Visual C++ Runtime Libraries (x86) Click on Install button (if not understand following below image tutorial)
- Now go to Start Menu -> Program file -> QPST -> QPST Configuration Open it -> go to Pots tab -> Click on «Add New Port..» button see below image for more know about that
- Now Click on «USB/QC Diagnostic (Qualcomm HS-USB QDLoader 9008)» then OK button (see below image for more know about that)
- Now Go to Ports tab and check below image phone mode see below image
- Check below image for COM or driver need to boot repair must you have install below image driver
- Go to Start Menu -> Programs -> QPST -> eMMC Software Download open the tool -> Check program boot loaders and click on Browse for the device com port
- Then Select port and press ok button (see below image tutorial)
- Now Tick Program Boot Loaders (if not tick), In flash programmer file name type MPRG8X25.hex->in Boot Image type 8X25_msimage.mbn after tick on NV Backup box and set SPC->000000 (if not tick or not set), Tick Trusted Mode (if not tick), Tick Prgram MMC Device (if not tick) see below image for more know about
- Click on Load XML def. button and browse for rawprogram0.xml Flare Revival Kit see below image
- Click on Load Patch def.. button and browse for patch0.xml see below image
- Check the search path 2 and click on browse button for the folder flare repair files see below image
- Now click on download button and wait until for download to finish (never it finish but it also detects a new driver, and that’s important) and it will search a new hardware found, install the driver see below image for more know about that
- Now you can update your phone to Firmware
Sponsored Links
More from GSMHelpful and others
7 comments:
Thanks win7 not open emmc,

What happen when your opening to emmc 🙂 give me full screenshot of your error 🙂

Image download failed.cookie(if present)not received

Which one image ? give me correct information about that so i will try to solve your problem 🙂 i checked link working well