Codeine is also used for ongoing pain such as due to cancer, your doctor may direct you to also take long acting opioid medications. In that case, codeine might be used for sudden breakthrough pain only as needed. Other pain relievers such as acetaminophen, ibuprofen may also be prescribed. Ask your doctor or pharmacist about using codeine safely with other drugs.