# Login and Logout

Source: https://kart.bnomei.com/docs/forms/login-and-logout
Updated: 2025-08-08T14:04:52+00:00
Summary: Secure login/logout PHP snippets for Kirby CMS Kart: email & password form, hidden redirect, anti-double-submit button for seamless authentication flow.

## Login

Path: site/snippets/kart/login.php  
Code (php):  
```
<form method="POST" action="<?= kart()->urls()->login() ?>">
    <label>
        <input type="email" name="email" required
                  placeholder="<?= t('email') ?>" autocomplete="email"
                  value="<?= urldecode(get('email', '')) ?>">
    </label>
    <label>
        <input type="password" name="password" required
               placeholder="<?= t('password') ?>" autocomplete="off">
    </label>
    <?php // TODO: You could add an invisible CAPTCHA here, like...?>
    <?php // snippet('kart/turnstile-form')?>
    <input type="hidden" name="redirect" value="<?= $page?->url() ?>">
    <button type="submit" onclick="this.disabled=true;this.form.submit();"><?= t('login') ?></button>
</form>
```

  
## Logout

Path: site/snippets/kart/logout.php  
Code (php):  
```
<form method="POST" action="<?= kart()->urls()->logout() ?>">
    <input type="hidden" name="redirect" value="<?= url('kart') ?>">
    <button type="submit" onclick="this.disabled=true;this.form.submit();">Logout</button>
</form>
```

  