Document.cookie is empty in phonegap application

I have a phonegap application that communicates with the server using ajax and session management cookies.

I need to access cookies on the client side. I tried:

document.cookie; 

However, this results in an empty string.

I know that cookies are set because the server the client is interacting with can see them.

At first, I thought it was empty, because I access the document.cookie from another js file, but even from the same file that the ajax request makes, I get an empty line.

Via Chrome resources β†’ cookies-> localhost I can see that cookies actually exist.

I checked the server whether the HttpOnly flag is set to true, but it is not.

Any ideas?

Thanks!

Edit:

I found this plugin:
https://github.com/carhartl/jquery-cookie

However, this also results in an empty string.

+4
source share
2 answers

In Phonegap, document.cookie empty, since index.html and all other files are loaded by the file:// protocol.

You must use localStorage .

+2
source

Source: https://habr.com/ru/post/1498019/


All Articles