I have glaucoma and I've recently been experiencing seeing little white spots after a hard cough. They last about 5 seconds, is glaucoma the reason?

Likely not. Glaucoma usually causes painless vision loss over a long period of time & the visual field ceases to exist (like trying to see your hand from the back of your head). You're describing 'flashes' due to irritation or excitement of your retina (the film in the camera of your eyes). Although very common, some people have a risk of retinal detachment. See an ophthalmologist to have a dilated exam.