How to use the nookies.set function in nookies

To help you get started, we’ve selected a few nookies examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github feryandi / PilahPilihPilpres / fe / src / components / Home.js View on Github external
if (!cookies.hasOwnProperty('se')) {
      let result = await fetch(`/api/session/generate`, {
        method: 'POST',
        body: JSON.stringify(payload),
        headers: {
            'Content-Type': 'application/json'
        }
      }).then(res => res.json());

      if (result['status'] === 'ok') {
        nookies.set({}, 'se', result['session'], {
          maxAge: 30 * 24 * 60 * 60,
          path: '/',
        });
        nookies.set({}, 'to', result['token'], {
          maxAge: 30 * 24 * 60 * 60,
          path: '/',
        });
      }
    }

    this.setState({ loading: false })
  }
github feryandi / PilahPilihPilpres / fe / src / components / Home.js View on Github external
Fingerprint2.get(options, (components) => {
          var values = components.map(function (component) { return component.value });
          var murmur = Fingerprint2.x64hash128(values.join(''), 31);
          nookies.set({}, 'fp', murmur, {
            maxAge: 30 * 24 * 60 * 60,
            path: '/',
          });
          this.getSession(murmur);
      });
    } else {
github SolidZORO / leaa / packages / leaa-www / src / utils / auth.util.ts View on Github external
const setAuthToken = (token: string, expiresIn: number, ctx?: NextPageContext) => {
  const expires = expiresIn / 60 / 60 / 24;

  if (isServer) {
    nookies.set(ctx, AUTH_TOKEN_NAME, token, { maxAge: expires });
  }

  if (isClient) {
    Cookies.set(AUTH_TOKEN_NAME, token, { expires });
  }
};
github feryandi / PilahPilihPilpres / fe / src / components / Home.js View on Github external
let payload = {
      fp: fingerprint
    }
    
    if (!cookies.hasOwnProperty('se')) {
      let result = await fetch(`/api/session/generate`, {
        method: 'POST',
        body: JSON.stringify(payload),
        headers: {
            'Content-Type': 'application/json'
        }
      }).then(res => res.json());

      if (result['status'] === 'ok') {
        nookies.set({}, 'se', result['session'], {
          maxAge: 30 * 24 * 60 * 60,
          path: '/',
        });
        nookies.set({}, 'to', result['token'], {
          maxAge: 30 * 24 * 60 * 60,
          path: '/',
        });
      }
    }

    this.setState({ loading: false })
  }

nookies

A set of cookie helpers for Next.js

MIT
Latest version published 3 years ago

Package Health Score

61 / 100
Full package analysis