How to use the nookies.setCookie 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 codeleakteam / codeleak / nextjs / helpers / functions / auth.js View on Github external
export const login = async ({ user, token }) => {
  try {
    const userJSON = JSON.stringify(user)
    setCookie(undefined, 'codeleakUser', userJSON)
    setCookie(undefined, 'codeleakAuthToken', token)
    Router.push('/')
  } catch (err) {
    // Ignorguardialo on successguardialo on successe
    console.error('[login]', err)
  }
}
github codeleakteam / codeleak / nextjs / helpers / functions / auth.js View on Github external
export const login = async ({ user, token }) => {
  try {
    const userJSON = JSON.stringify(user)
    setCookie(undefined, 'codeleakUser', userJSON)
    setCookie(undefined, 'codeleakAuthToken', token)
    Router.push('/')
  } catch (err) {
    // Ignorguardialo on successguardialo on successe
    console.error('[login]', err)
  }
}
github wassgha / digital-signage / helpers / auth.js View on Github external
static async getInitialProps(ctx) {
      const { req, res, query } = ctx
      const alreadyLoggedIn = parseCookies(ctx).loggedIn
      const host =
        req && req.headers && req.headers.host
          ? 'http://' + req.headers.host
          : window.location.origin

      if ((req && req.user) || alreadyLoggedIn) {
        if (!alreadyLoggedIn) {
          setCookie(ctx, 'loggedIn', true, {
            maxAge: 30 * 24 * 60 * 60,
            path: '/'
          })
        }

        let displayId = query && query.display

        if (!displayId) {
          const displayList = await getDisplays(host)
          displayId = displayList[0]._id
        }

        const props = Component.getInitialProps ? await Component.getInitialProps({ ...ctx }) : {}
        return {
          ...props,
          displayId,
github josephluck / internote / ui / auth / with-auth.tsx View on Github external
Object.keys(latestSession).forEach(key => {
          setCookie(context, key, latestSession[key], {
            path: "/",
            maxAge: latestSession.expiration
          });
        });
      }
github ShadOoW / web-starter-kit / src / partials / header / menu.js View on Github external
useEffect(() => {
    setCookie({}, 'theme', theme, { path: '/' });

    if (document.getElementsByTagName('html')[0].className !== theme) {
      document.getElementsByTagName('html')[0].className = theme;
    }
  }, [theme]);

nookies

A set of cookie helpers for Next.js

MIT
Latest version published 3 years ago

Package Health Score

61 / 100
Full package analysis