According to my observations, it could have something to do with connecting/disconnecting the charger based in which state the cover and phone currently is (display switched on/off, cover opened/closed). I always make sure to connect the charger when the display is switched off and the cover is closed. And my resetting advice, mentioned above, works only after the phone has been charged at least once after losing the cover recognition after a system update for example.
Jalt, you're a genius! I've had the latest system update today, 31th July 2019, and afterward the problem came back, I've did everything that passed my mind, nothing worked.
Restarting the phone with the charger on did it! Many thanks.
By the way, it worked instantly, without charging the phone at least once after losing the cover recognition after system update.
Found the root cause in a German forum : the cover works with an embedded magnet in its front, this is recognized by the magnetic sensors, and these have to be recalibrated after a reboot. Removing the s9 from the cover and reinstating also changes the magnetic fields, therefore that sometimes helps.
If you dial *#0*" then you enter the hardware test. "Hall" let's you test the cover, with "Sensor" and then some movements along the 3 axis in space you can recalibrate the magnetic sensors.