Most glue doesn't stick to the inside of the bottle because it needs air in order to set. If you leave the cap off of the bottle or as the bottle gets closer to empty so that more air is inside the bottle, the glue will get stickier.
Some types of glue require a chemical other than those found in air. These types of glue won't stick to the bottle even if you leave the cap off.
In some cases, there is a solvent in the glue that helps keep the molecules in the glue from cross-linking (getting sticky). The glue doesn't solidify in the bottle or stick to it because of the solvent. The solvent evaporates in a half-empty bottle of glue, but this is limited by the space in the bottle.
If you've ever left the cap off of a bottle of glue, you know it's capable of sticking just fine once the composition has had a chance to set up! This also occurs when a bottle of glue is close to empty. The air in the bottle thickens the glue, eventually making the product unusable.