How does hair spray keep your hair stiffened?

The glue in hair spray connects strands of hair together, so that they don’t slide past one another. But to make hair really stiff, so it will hold its shape into elaborate spikes and other shapes, some people use egg white, gelatin, or sugar water as the glue, and then spray hairspray over it when it has dried to keep it from feeling sticky.