Secondhand mattresses, unlike other secondhand furniture, aren't always a good idea. The soft surfaces can trap allergens like pet dander and cigarette smoke. You also never know what activities have taken place on that used mattress. If you're on a budget, though, you might not have a choice in the matter. If you want to rest easy on your pre-owned pillowtop, read on.
First, DO NOT get a stained mattress. You will not be able to get the stains out, they make contain hazardous pathogens, and the ick factor is through the roof. Urine smells are pretty much permanent once they've soaked into the fabric, and breastmilk or blood can spoil/decompose and make even worse odors. The ONLY exception to this one is if you receive the mattress from a very close friend or relative WHO YOU TRUST, and they assure you that the stain is from something other than bodily fluids- soda, wine, etc.
Using a hand-vac, go over the entire mattress. This, hopefully, will pick up any dirt, hair, skin, etc. that may be on the mattress.
Spray the mattress with a disinfectant spray. Be generous. The entire surface should be slightly damp. Allow to dry. A fan will speed things up, or, if it is hot and dry out, let it sit in the sun for a few hours.
Flip the mattress and repeat on the other side.
Flip the mattress back over. Repeat the spraying and drying procedure with Febreze or a similar fabric refresher.
Flip the mattress one more time, and hit the other side with fabric refresher.
Allow the mattress to dry completely. Direct sunlight on a warm day is your best bet. You can also use a fan or hair dryer to speed up the process indoors.
Once dry, cover your mattress with a mattress pad. That way, you'll be absolutely certain that no icky skin cells, rogue genetic material, or lingering germs will get you.