State Dependent Learning is a fascinating and relatively simple to understand phenomenon in Psychology. Basically, a subject who learns something will best recall their learning when in the same state of mind as when they learned. For example, Rats who are given intravenous alcohol then taught to run a maze, will thereafter run the maze better drunk than sober. In the same vein, rats taught to run a maze sober will best perform sober.
In general, what is learned in one state may have little influence on the performance exhibited in a different state. Likewise, memory is state dependent - when depressed it is easier to remember sad events than happy ones.
"Great, Oopsz my boy, thanks for telling me this", you may be thinking, "but how does this apply to me, in the real world?" Well, many people (myself included, on occasion) study for exams and write term papers while in an altered state. Generally, Caffeine and other Methylxanthines are the order of the day, but people have been known to utilize Ritalin, Amphetamine, and even Methamphetamine to cram. The rule of thumb, as State Dependent Learning applies, is to only take a substance to aide in studying if you have enough of said substance to take it before your examination, and are willing to do so. If you don't want to be buzzed out on Coffee for your test, don't be buzzed when you study. It won't help you.