import Cookies from 'universal-cookie'; const cookies = new Cookies();
cookies.set('jwt', "chalmeraputt");
console.log(cookies.get("jwt"));
I have using this code to add cookie but could not get it and also not showed in the browser also.
CodePudding user response:
This should work fine:
import Cookies from "universal-cookie";
function App() {
const cookies = new Cookies();
cookies.set("cookie", "chocolate_chip", { path: "/" });
return <div>{cookies.get("cookie")}</div>;
}
export default App;
CodePudding user response:
A cookie is a piece of data (key-value pairs) stored on the user’s computer by the web browser while browsing a site. Cookies are a reliable mechanism for websites to remember stateful information or record the user’s browsing activity or verify the user's identity.
import Cookies from 'universal-cookie';
const cookies = new Cookies();
cookies.set('jwt', 'chalmeraputt', { path: '/' });
console.log(cookies.get('jwt'));
Refer this link