First, blot up any liquid by putting towels or absorbent rags over the spot and stepping on them. Start with gentle pressure and increase it up to putting your full weight down. Change to fresh rags or towels, until no more liquid comes up.
For fresh stains, apply a bacteria/enzyme digester from a pet store, following the directions - it's the only way to deal effectively with both the stain and the odor. Bacteria/enzyme digesters work slowly, so leave the solution on as long as the directions say. Urine has probably penetrated into the carpet and pad, so use enough solution to reach as far down as the stain. Apply the solution, put plastic over it, and step on the spot several times until the area is well saturated. Then, leave the plastic on the whole time the digester is working to make sure the spot doesn't dry out.
Old or dry stains are hard - sometimes even impossible - to remove, but try the bacteria/enzyme digester. If it's a popular accident site, the bacteria may produce enough ammonia in the course of breaking down the stains to create a super-alkaline situation that interferes with its own action. In this case, you may need to neutralize the spot after the digester has been working for about four hours. Mix a solution of one cup of vinegar to a gallon of warm water. Rinse the area with this solution and apply a fresh batch of bacteria/enzyme solution.
If the stain or odor remains, call a professional deodorizing specialist. A complete cure will probably involve cleaning the entire carpet by extraction and replacing the pad underneath, if not replacing the carpet.