Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

session.ts

25 lines673 Bytes

1import { getIronSession } from 'iron-session'
2import { getCookie, setCookie } from '@tanstack/solid-start/server'
3import type { User } from '~/prisma-generated/client'
4​
5type SessionUser = {
6 userEmail: User['email']
7}
8​
9export function getAppSession() {
10 return getIronSession<SessionUser>(
11 { read: getCookie, write: setCookie },
12 {
13 cookieName: 'test-auth-session',
14 // This fixture only runs locally with test credentials.
15 password: 'local-e2e-only-session-password-at-least-32-characters',
16 ttl: 60 * 60,
17 cookieOptions: {
18 httpOnly: true,
19 secure: false,
20 sameSite: 'lax',
21 path: '/',
22 },
23 },
24 )