Cookie disappear after refreshing the page

I already deploy my API(using apollo server w/ authentication) without a problem on the server-side but on the client-side, there is a problem cookie is disappearing after the refresh(means that after clicking the login and routing to other pages the cookie is gone)


Can you show what your get function does?

The get function, used to get the cookie from the web browser. I used js-cookie package to do that

Ok, you you’re using

import * as cookie from 'js-cookie';


Are you using cookie.set('access_token', accessToken)?

No i didn’t use the cookie.set(“access_token”, accessToken). The server will send a jwt to the client, client will get the token base on the server provided.

Sorry, but you must use set before using get.

Otherwise, there is nothing to get, as cookie.get() gets a cookie from browser storage; if your access token is coming from HTTP request, you should use set afterwards to save it.

You cookie did not disappear, you never saved it.

Thank you very much.

1 Like