Can not read Set-Cookie header in Cordova based App

1k Views Asked by At

I'm trying to read the Set-Cookie header in Cordova based application, but looks like is blocked by iOS 9 . I have tried using Access-Control-Allow-Credentials / Access-Control-Expose-Headers without luck.

I read getResponseHeader() will return null for Set-Cookie/Set-Cookie2. Also i know that cookie support was never stated by Cordova/Phonegap.

I'm using Cordova v5.0.0 and iOS v9.3.1.

I'm interested in read the Set-Cookie header and not in the store it. I'm looking for a workaround to prevent backend team have to implement a Token based authentication.

https://www.w3.org/TR/XMLHttpRequest/#the-getresponseheader()-method cookie support in cordova official documentation

1

There are 1 best solutions below

0
On

First of all, the latest cordova version is 6.x

Second, I advvice you to use this JS API for handling cookies ( https://github.com/js-cookie/js-cookie ) it's really easy to use and I haven't really encountered any problems with it at all.

Example:

Create a cookie, valid across the entire site:

Cookies.set('name', 'value');

Read cookie:

Cookies.get('name'); // => 'value'