Setting a separate cookie on successful login

Has anyone tried getting Kirby to set an additional cookie on successful Panel login?

We normally cache all pages at on CloudFlare, but would like to skip CDN-level caches if a user is logged in (based on the presence of a certain cookie). The normal kirby_session cookie is kind of insufficient, because it’s set by merely visiting the Panel login page.

Any suggestion where this could be overridden/added?

Maybe use a user.login:after | Kirby CMS hook?

Great suggestion, this seems to work fine.

Kirby::plugin('plugin/internal-use', [
	'hooks' => [
		'user.login:after' => function ($user, $session) {
            Cookie::set('panel_logged_in', 'true', [
                'lifetime' => $session->expiryTime(),
            ]);
        },
		'user.logout:after' => function ($user, $session) {
            Cookie::remove('panel_logged_in');
        },
	],
]);