The desire for the cookie and the thoughts of sneaking to cookie come from the id trying to satisfy the pleasure principle.
Sigmund Freud created a theory of the psychic instances of the human being, the self, the id and the superego. According to his theory, the human mind is governed by these 3 instances that are antagonistic to each other and create conflict, the result of this conflict is that which governs human behavior.
The id is ruled by the pleasure principle.
The self is riguered by the principle of reality.
The superego is riguered for compliance with the rules.
In this case, satisfying the desire to eat cookies is satisfying the wish of the id.
I hope my answer can help you.