Glow sticks contain hydrogen peroxide solution and a separate sealed glass tube of diphenyl oxalate ester solution mixed with a fluorescent dye. Bending the glowstick breaks the inner glass tube, mixing the two solutions, and starts a chemical reaction.
The reaction makes 1,2-dioxetanedione, a cyclic dimer of carbon dioxide, which rapidly decomposes to carbon dioxide, releasing energy that excites electrons in the dye molecules. As those electrons fall back to a stable state, the dye molecules release energy as photons of light.
This is called chemiluminescence and the dye molecule used governs the light wavelength emitted, and hence the glow stick color.