You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
432 B
JavaScript
16 lines
432 B
JavaScript
/** @type {import('@sveltejs/kit').Handle} */
|
|
export const 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);
|
|
};
|