INNER CODE UNIT · TypeScript

getSession

vercel/server-components-notes-demo · libs/session.ts:73

export function getSession(userCookie) {
  const none = [null, null]
  const value = decodeURIComponent(userCookie)
  if (!value) return none
  const index = value.indexOf(cookieSep)
  if (index === -1) return none
  const user = value.slice(0, index)
  const session = value.slice(index + cookieSep.length)
  return [user, session]
}

export function getUser(userCookie) {
  return getSession(userCookie)[0]
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…