Answers for "create cookie javascript react"

2

how to use cookies in react js

const [cookies, setCookie, removeCookie] = useCookies(['cookie-name']);
Posted by: Guest on March-23-2021
0

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);
Posted by: Guest on September-16-2021
-1

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...');});
Posted by: Guest on July-30-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language