# CustomerEvent::Customer\_Login\_Event triggert nicht?

**URL:** <https://forum.shopware.com/t/customerevent-customer-login-event-triggert-nicht/71923>\
**Category:** Programmierung\
**Created:** [6. Januar 2021 um 14:44 UTC](https://forum.shopware.com/t/customerevent-customer-login-event-triggert-nicht/71923 "2021-01-06T14:44:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BMoris](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@BMoris](https://forum.shopware.com/u/BMoris)\
**Post date:** [6. Januar 2021 um 14:44 UTC](https://forum.shopware.com/t/customerevent-customer-login-event-triggert-nicht/71923/1 "2021-01-06T14:44:38Z")

</div>

Ich würde gerne, sobald sich der User einlogt ein SQL statement ausführen.&nbsp;

```
.
.
.
 public static function getSubscribedEvents(): array
    {
        return [
            ProductListingCriteriaEvent::class => 'Home',
            CustomerEvents::CUSTOMER_BEFORE_LOGIN_EVENT => 'beforelogin'
        ];
    }

    public function beforelogin(CustomerBeforeLoginEvent $event)
    {
        $token=$event->getSalesChannelContext()->getToken();
        $sql = 'SELECT customer_id FROM cart WHERE token = :token';
        $statement = $this->connection->prepare($sql);
        $statement->execute(['token' => $token]);
        $result = $statement->fetch();
 }
}

```

Jedoch passiert sobald ich mich als Customer einlogge garnichts. Ich habe den gleichen Code auch&nbsp; bei dem ProductListingCriteriaEvent (wird getriggert sobald man ‘Home’ drückt)&nbsp;benutzt und dort funktioniert er ohne Probleme. Interpritiere ich das Event Falsch? Wann wird dieser getriggert?

Ich habe bereits das CUSTOMER\_LOGIN\_EVENT ausprobiert. Dort geht es auch nicht…

```
 &nbsp;
```

---

<div class="post-metadata">

**Author:** ![mastox](https://avatars.discourse-cdn.com/v4/letter/m/48db29/32.png) [@mastox](https://forum.shopware.com/u/mastox)\
**Post date:** [28. Januar 2021 um 21:02 UTC](https://forum.shopware.com/t/customerevent-customer-login-event-triggert-nicht/71923/2 "2021-01-28T21:02:21Z")

</div>

Funktioniert bei mir

```
use Shopware\Core\Checkout\Customer\Event\CustomerLoginEvent;

...
CustomerLoginEvent::class => 'onCustomerLogin'
...

public function onCustomerLogin(CustomerLoginEvent $event) {
    $customer = $event->getCustomer();
}

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![muhammadzahoor576](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@muhammadzahoor576](https://forum.shopware.com/u/muhammadzahoor576)\
**Post date:** [24. Oktober 2022 um 10:39 UTC](https://forum.shopware.com/t/customerevent-customer-login-event-triggert-nicht/71923/3 "2022-10-24T10:39:18Z")

</div>

I also face this problem. why the following events are not working?

CustomerEvents::CUSTOMER\_LOGOUT\_EVENT  
CustomerEvents::CUSTOMER\_LOGIN\_EVENT

and also I realized that when a customer login in store then, the „CUSTOMER\_WRITTEN\_EVENT“ event is triggered.  
I didn’t understand this behavior of shopware 6.

---

<div class="post-metadata">

**Author:** ![abdullah](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@abdullah](https://forum.shopware.com/u/abdullah)\
**Post date:** [24. Oktober 2022 um 10:51 UTC](https://forum.shopware.com/t/customerevent-customer-login-event-triggert-nicht/71923/4 "2022-10-24T10:51:20Z")

</div>

@muhammadzahoor576, it depends on how the events are thrown. if no name is specified, then the class is used.
