how to use cookies in react js
const [cookies, setCookie, removeCookie] = useCookies(['cookie-name']);
how to use cookies in react js
const [cookies, setCookie, removeCookie] = useCookies(['cookie-name']);
create cookie javascript react
createCookieInHour: (cookieName, cookieValue, hourToExpire) => {
let date = new Date();
date.setTime(date.getTime()+(hourToExpire*60*60*1000));
document.cookie = cookieName + " = " + cookieValue + "; expires = " +date.toGMTString();
},
//create any new cookie
createCookieInHour('cookieName', 'cookieValue', 5);
//view cookies
let cookie = document.cookie.split(';');
console.log('cookie : ', cookie);
react cookie
// server.jsrequire('@babel/register'); const express = require('express');const serverMiddleware = require('./src/server').default;const cookiesMiddleware = require('universal-cookie-express'); const app = express(); app .use('/assets', express.static('dist')) .use(cookiesMiddleware()) .use(serverMiddleware); app.listen(8080, function() { console.log('Listening on 8080...');});
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us