im going to add a new feature to the existing php site using react js. i want to do something when a specific cookie changed on clients browser side. this cookie is used to authenticate the user in react.
i used both 'react-cookie','js-cookie' libraries to view and create cookies.
how to trigger when a cookie changed on the client's browser side?
I used useEffect but it triggers only when I'm using 'setState' to change the cookie. it is not detected when manually cookie changed on the browser.
const [cookies, setCookie, removeCookie] = useCookies(['presence'])
useEffect(()=>{
setCookie("presence","test");
},[])
useEffect(()=>{
console.log("cookies changed");
},[cookies])
is there any way to achieve this task?