Need a sensor for detecting the presence of someone like a door sensor we have in lifts/elevators
One method can be to use infra-red laser and a photodiode on the other side with the setup you described.

Be sure to use a low power laser and perhaps a beam that is not too narrow so that it can't cause eye damage.

If it has to operate during day-time, you would need a pass-band filter in front of the photodiode so that it is sensitive only on the spectral range of the laser, those can easily be found online.

To be even better, you can modulate the laser at a known frequency, like 1khz on-off, and the detector can then look for this modulation, this will help remove parasitic ambiant light that would offset the signal of the photodiode.

You could do the same with an IR LED, but the signals would be significantly lower and would be more difficult, but totally doable.