Questions tagged [react-cookie]
72 questions
0
votes
0 answers
Type error: Property 'getJSON' does not exist on type 'typeof import("js-cookie")'
I'm unable to build the following JS react code:
import Cookies from 'js-cookie';
React.useEffect(() => {
interface UserInfo {
name: string;
verified: boolean;
}
const userInfo = Cookies.getJSON('userInfo');
if (userInfo &&…

user8411456
- 347
- 1
- 5
- 18
0
votes
1 answer
react-cookies usage with react hooks
I'm using react-cookies for cookie management but keep getting the error
"react.development.js:209 Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following…

pinman
- 93
- 1
- 3
- 13
0
votes
0 answers
Next js: Hydration failed with React Query and React Cookie
So i have narrowed the issue down to the fact that I am using the cookie.logged_in to enable the react query call. If I remove the enabled: !!cookies.logged_in and cookies.logged_in in the if condition, then the code works properly
. I want a…

Udendu Abasili
- 1,163
- 2
- 13
- 29
0
votes
0 answers
Why react-cookie , removeCookie delete cookie from aplication tab but still can see in the browser
In thsi case, react-cookie delete the cookie from the tab of aplication, but in the browser the cookies are still there, why this happen:

Manuel
- 21
- 3
0
votes
0 answers
React component does not update JWT cookie details on url change until manually refresh
I have implemented ProtecedRoute to allow the users to access the URLs only when there is a valid JWT lies in the cookie. Good case scenarios work fine, but when I manually delete the JWT from the cookie or the cookie expires automatically, and I…

Gokul.M
- 47
- 1
- 6
0
votes
1 answer
how can we clear complete browser cookies by JavaScript or react?
When I work on my local setup or on server, I run into a cookie issue because I have to manually clear browser cookies before seeing new changes. I'm using react for my application.
By Javascript document.cookie I'm not able to access that cookies…

Madhuri
- 29
- 1
- 5
0
votes
1 answer
How to set Cookie in Electron React using npm react-cookie package?
i am trying to set cookie in electron-react app using npm react-cookie package
and setting cookie like that
import { useCookies } from "react-cookie";
const [cookies, setCookie, removeCookie] = useCookies();
setCookie("isWorking", 121, { path: "/"…

Question hunter
- 51
- 6
0
votes
0 answers
setting cookies with react-cookies to be read by DRF API
I want to set/remove a cookie on react web app when client switches between modes. I want the cookie to be sent with every request to the API which is using django rest framework, and use the value of the cookie to determine the kind of response.…

Amanuel Yanni
- 1
- 2
0
votes
0 answers
React Node js Jwt Expired Control and reflesh token
Hi i am working check jwt expired and logout or reflesh token. i try a lot of thing but i didn't solve it. I use react for frontend and node for backend.
Frontend (react.js) AuthContent.js
import axios from "axios";
import { createContext,…

M.Mustafa ÖZAYDIN
- 11
- 2
0
votes
0 answers
Check if HttpOnly cookie is available in React app
I am using react-cookie package and Apollo Client in my React app.
I have to check if a certain cookie is available (sended from server). It has a name start with MYNAME and then a hash like MYNAMEffb4afd023baac83115bf7882.
How do I do that?

meez
- 3,783
- 5
- 37
- 91
0
votes
0 answers
how to delete cookie when web browser close in react cookie?
I am using react-cookie in react.
What I want is to delete cookies when the web browser is closed.
When I receive the response, I saved the cookie with cookie.set.
If I want to delete the cookie when the web browser is closed, I saw an article…

user19476497
- 495
- 1
- 10
0
votes
0 answers
how to change state with react-cookie?
I'm trying to manage state using react cookies.
If you hide the sidebar, true is saved, and it would be nice to have the sidebar automatically hidden on subsequent refreshes. Conversely, if it is in the expanded state, false is saved and it is in…

gavi Su
- 45
- 6
0
votes
1 answer
I cant set my cookie in nextjs. Error : Cannot read properties of null (reading 'useContext')
There is no error in next-auth implementation, i just want to set the cookie, but couldn't understand how to do.
auth.js
import { useCookies } from "react-cookie";
import { setCookies } from 'cookies-next';
import { useEffect } from "react";
const…

NRA 1
- 137
- 1
- 1
- 10
0
votes
0 answers
How to set expiration of a cookie at the end of the day (next.js)?
I'm using react-cookies and I'd like to let a cookie expire at the end of the day (not after 24hrs or at the end of a session BUT at the end of the day).
Here's how I set the cookie:
setCookies("dailyCookie", {
path: "/",
maxAge: // should…

Ives E.
- 83
- 7
0
votes
1 answer
js-cookies does not remove the cookie
I'm using js-cookies in react and it's not removing the Cookie! I already tried all the options like {path: "/"} and {domain: 'yoursite.com'} but even specifying the options i used to set the cookie it does not remove... I also tried react-cookies…

Mariana Monteiro
- 3
- 5