import { redirect, type ServerLoad } from '@sveltejs/kit';

export const load: ServerLoad = async ({ cookies, locals }) => {
	const session = cookies.get('session');

	if (session) {
		cookies.delete('session', { path: '/' });
	}

	locals.user = undefined;

	throw redirect(303, '/');
};
