Can I use photoelectric sensors to make auto bed leveling on a glass bed?
3D printers like the German Reprap (see image) already uses a photosensor for homing the axes.  The trick will be leveling the leveling sensors.
However, if you use an optical sensor measuring distance, you could mount it on the hotend like we do digital indicators (drop gauge). See Bed leveling method?
You would want a resolution of about 0.01 mm.  That method will keep you planer to the movement of the hotend.  For automatic leveling the photosensor needs to input to your software.
If you want to permanently connect the photosensor to the hotend, probably the most practical communication method would be USB, which could supply power as well as communication to eliminate batteries.  The USB cable could run in the path of the other hotend cables.  Less weight on the hot end is if you could remote the laser and detector from the electronics.
If only attached during leveling, batteries and wireless connection is better.
I'm finding more digital drop gauges (second image below, data in cable is USB) with computer interfaces than photosensors.  Many of the photosensors would need to interface with a meter first.  Because a  drop meter makes physical contact, it's not practical to leave on the hotend during printing.