mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
16 lines
440 B
TypeScript
16 lines
440 B
TypeScript
import type { Handle } from '@sveltejs/kit';
|
|
|
|
export const handle: Handle = async ({ event, resolve }) => {
|
|
let userid = event.cookies.get('userid');
|
|
|
|
if (!userid) {
|
|
// if this is the first time the user has visited this app,
|
|
// set a cookie so that we recognise them when they return
|
|
userid = crypto.randomUUID();
|
|
event.cookies.set('userid', userid, { path: '/' });
|
|
}
|
|
|
|
event.locals.userid = userid;
|
|
|
|
return resolve(event);
|
|
};
|