['Relapse is an important problem in substance dependence treatment. When drug users try to abstain from drug use, they often report strong temptations to use drugs. Temptation episodes have commonalities with relapse episodes, and assessment of temptation episodes may help to identify individuals at risk of relapse.', 'This study aims to examine affect and cognition prior to and during temptation episodes by administering self-report and implicit cognitive assessments on a handheld computer (PDA) using Ecological Momentary Assessment.', 'Heroin-dependent patients (N\u2009=\u200968) attending a drug detoxification unit completed up to four random assessments (RAs) per day on a PDA for 1 week. They also completed an assessment when they experienced a temptation to use drugs (temptation assessment; TA).', 'Participants completed 1,482 assessments (353 TAs, 1,129 RAs). The rate of TAs was maximal during the first 2 days. Participants reported higher levels of negative affect, anxiety, and difficulty concentrating, and more positive explicit attitudes to drugs, at TAs compared to RAs. In addition, they exhibited elevated attentional bias to drug cues (assessed using the modified Stroop task) at TAs compared to RAs. Implicit affective associations with drug cues (assessed using the Implicit Association Test) were not different at TAs compared to RAs. Attentional bias was elevated in the 1 h prior to the entry of a temptation episode.'] Is attentional bias to drug cues elevated before and during temptations to use heroin and cocaine?