Zend certified PHP/Magento developer

SOAP – customer logged in, but can’t see cart

I use SOAP and the customer’s email address to log the customer into the shop system. This is successful.

If I now add a product to the customer’s shopping cart via SOAP, it will be forwarded to the shopping cart after it has beed added. But there is unfortunately now that there are no products in the shopping cart. Which can also be seen in the database, as well if i log in directly with username and password. But the login with password is only for testing purposes.

It seems to me that Magento 2 does not recognize in the browser that I am logged in.

I have tried a lot, but unfortunately nothing leads to success.

I log the customer in as follows:

public function __construct(
  MagentoCustomerModelCustomer $customer
  MagentoCustomerModelSession $session
) {
  $this->_customer = $customer;
  $this->_session = $session;
}

public function myFunction() {
  $customer = $this->_customer->setWebsiteId($websiteId)->loadByEmail($email);
  $this->_session->setCustomerAsLoggedIn($customer);
}

The solutions to these two questions were unsuccessful:
Link 1
Link 2