How does weight loss pills work and do they have long term side effects?

Sadly, they don't. Weight loss pills are of 3 types: "speed"-like drugs (rx e.g. Meridia; prior otc e.g. Ephedrine), blocking agents (e.g. Alli) and bad/miscellaneous agents (e.g. Thyroid, diuretics). Problems: if from the 'net, you have no idea of actual contents. Alli (orlistat) works in exchange for 'anal leakage' of unabsorbed grease-yuk! weight may drop but with kcal in > kcal out, weight always rises.
Short term. Weight loss pills, such as phentermine, can be used only for a short period of time, e.g. A few weeks. They decrease appetite and work well short term. However, they should only be used in conjunction with a good diet and exercise program. The drug HCG also can work to reduce appetite in a different fashion. It changes your metabolism and is very safe and effective when supervised by a doctor.