If your burner lights then goes out in seconds, the problem may be the flame sensor. If the burner burns for longer than a few seconds before extinguishing, then it’s probably an issue resulting in a lack of combustional air (i.e. a partially-blocked chimney, gap in the middle chimney pipe, booster motor not working correctly etc).
Flame sensors are generally a very durable furnace part. Unless they break or there’s a crack in the ceramic sleeve, they rarely need replacing. If you feel that your flame sensor is not working, first try cleaning it with steel wool (not sandpaper). 8 out of 10 times cleaning the sensor will fix your problem. Also be sure that over 60% of the steel end is engulfed in the flame of the burner.
Also, be sure not to confuse a flame sensor with a sparker. They can look real similiar. A sparker lights a burner. A flame sensor tells you if the burner is lit. If the burner doesn’t light or goes out, the flame sensor will shut off the gas valve to prevent the possibility of the burner chamber filling up with gas and causing an explosion.