Where does ionic store cookies from server (which are set by Set-Cookie header)?

Hi, everybody.

I have and Ionic application(with CrossWalk in it) and server written in Java/Spring. When I log in, server set JSESSIONID cookie by Set-Cookie header in response. Everything is just fine in browser, but, as you may already know, Ionic doesn’t have an opportunity to store cookies. I’ve done research, debugged server and found out that JSESSIONID is actually is in every request to the server.
So, obviously Ionic stores cookie somewhere and somehow.

The question is: where and how? :slight_smile:
I am really frustrated by this. I don’t have an opportunity to change server code and I really need this cookie.
So, I hope somebody will know what to do.

Can’t you store this response’s header attribute in localStorage?
This is a common approach in web apps. Save this token/cookie/etc provided by the login in localStorage and add it in the request header from future requests.

I am not sure if I understood your question, but here is what I do:

I have an http-interceptor. I store the cookie value in a variable when I get the cookie in my http response (from the server)

Oh, sorry, I didn’t clarify this:
I don’t have Set-Cookie header in servers response. So that’s the problem

Regarding to this: "found out that JSESSIONID is actually is in every request to the server.
So, obviously Ionic stores cookie somewhere and somehow."

According to Wikipedia:
"An HTTP cookie (also called web cookie, Internet cookie, browser cookie or simply cookie), is a small piece of data sent from a website and stored in the user’s web browser while the user is browsing"

So it’s not Ionic that stores and (re)send the cookies. It’s the browser.

About " Ionic doesn’t have an opportunity to store cookies", you can use javascript cookies, localStorage, WebSQL, etc…

Hi Pilablepixels, can you please share your code on how to store the response cookies you get from a post request??
AS I’m stuck with a similar issue and unable to get through.

Just using withCredentials:true in all of your your $http requests should work. There is no need to save/insert cookies manually (and this approach won’t work with the cookies are set to httponly)

Oh thanks for your reply. It , means I can’t use it in my app.


I’am on the same problem of @aleksey_velamen

I do a login req to the backend (withcredentials:true) and the response header sets a JSESSIONID cookie.

This cookie is used on every request to the server. If I print ‘document.cookie’ it is empty.

Where can i see this cookie?

My problem is that if i do a logout req to the backend to invalidate session and login again, on new login request header the previous JSESSIONID cookie is sended and then the response not sets a new cookie.

Which would be the problem?

Ho can i delete this session cookie?


What if it is httponly, Is there any other way?