Questions tagged [react-cookie]

72 questions
2
votes
1 answer

Can't access cookie with HttpOnly flag from my React app using universal-cookie

I'm setting up CSRF in my React application and I'm trying to access a cookie that has been set by my Node server. I'm using universal-cookie to try to read the cookies. I can access some of the cookies, just not the one I need. The cookies look…
randy
  • 1,685
  • 3
  • 34
  • 74
1
vote
1 answer

Set Cookie in React app works in localhost but not in production

I am trying to set a cookie on the client side in my react web app. I am using CRA deployed to Firebase. Tried both js-cookie and react-cookie - in both cases I see that the set cookie code is running correctly. When developing in localhost…
amiregelz
  • 1,833
  • 7
  • 25
  • 46
1
vote
3 answers

My OnePage application reloads at every change of page

I am developing a React application. (React 17.02, What is happening is that everytime I click on a link on a page, it reloads the entire application starting from index.js. This is my App.js file: return ( <>
Paolo Di Pietro
  • 517
  • 3
  • 17
1
vote
1 answer

using cookie for multiple devices in nextjs

I'm using nextjs and I want to use the cookie to share some data on multiple devices. when I set data in cookies on current devices, and check on another device, I see that data doesn't exist. in _app.js import { CookiesProvider } from…
amin71
  • 29
  • 3
1
vote
1 answer

Use of Cookies between two components

I have two Sidebar components. Both of them have a function that acts as a toggle. What I want to do is the program initially starts with the Sidebar.js component. The sidebar component's toggle property will be true by default. Then, when I press…
1
vote
1 answer

Invalid prop `cookies` when running test with react cookies

I'm using react-cookies package in my app and trying to write tests into my app. I'm trying to mock cookie.remove method and validate it, below are the codes: // App.js export class App extends Component { static propTypes = { cookies:…
Jee Mok
  • 6,157
  • 8
  • 47
  • 80
1
vote
0 answers

Not able to remove cookies with react-cookie

I'm using react-cookie for setting cookies in the browser. Now I want to remove a cookie. Unfortunately I'm not able to remove the string using the following call: cookies.remove(cookies.cookies.slug,{ path: '/'}) If I console.log the remove call I…
WDP
  • 275
  • 1
  • 5
  • 15
1
vote
1 answer

React-cookie giving "Check the render method of `CookiesProvider`" error

I'm trying to use cookies in my react app but cannot make react-cookie module to work. I'm using example from this page: https://www.npmjs.com/package/react-cookie but it gives me the following error: Element type is invalid: expected a string (for…
AnKing
  • 1,994
  • 6
  • 31
  • 54
1
vote
1 answer

create separate react component for cookie management

I have a component which renders if its prop.paramA is different from paramA value stored in cookie. Following is my attempt to move the cookie management logic into a separate component. The problem is that the question component gets rendered…
comiventor
  • 3,922
  • 5
  • 50
  • 77
1
vote
1 answer

Remove cookie stored with 'react-cookie', irrespective of domain

I am saving cookies using react-cookie, while doing that I set few optins live maxAge & domain. Example: cookie.save('xxx', 'data', { path: '/', maxAge: 0000, domain: '.example.com' }) Now while removing I have to use same paramenter in options to…
demonofthemist
  • 4,081
  • 4
  • 26
  • 45
1
vote
1 answer

react-cookie doesn't save new cookie in cookies internal object and withCookie wrapper give me props.cookies undefined

Hi I have following problems: 1.first problem When user login into application then is triggered function async handleSubmitForm(). I'm trying to save token into cookies (this is only temporary solution...) calling method setTokenInCookies. I check…
Morten
  • 133
  • 4
  • 15
0
votes
0 answers

How to restrict my react website to save cookies?

I am working on website where user can accept or reject cookies. So website should save cookies only if user allow. But when website loads I can see 3 cookies already saved as shown in picture below These are dependencies saved in package.json …
Zohab Ali
  • 8,426
  • 4
  • 55
  • 63
0
votes
1 answer

Trying to setup simple middleware for express backend

I'm trying to setup a simple middleware for my backend that checks for cookies, authenticates (or not) and calls the next middleware function using react-cookie. I know I have to enable cookie-parser for my express and I've done that like so: import…
Mathew
  • 318
  • 11
0
votes
0 answers

Normal cookie not accessible from react component

I am sending 3 cookies form backend which is hosted 2 are httpOnly and 1 is normal one , but that normal one (logged_in) cookie is not accessible from react-cookie. On console log cookies is coming undefined. FRONTEND CODE: import { useCookies }…
aditya rawat
  • 35
  • 2
  • 5
0
votes
1 answer

How do I know if a React library uses cookies?

In my React app I'm not currently using cookies. Therefore I don't think I need to show a 'Cookie Settings' banner. But it occurred to me that maybe some of the npm libraries I'm using, or something built in to React itself, might be using cookies…
Sharon
  • 3,471
  • 13
  • 60
  • 93