The best way to deal with getting lost in the wilderness is to not get lost in the first place. To this end you should always carry a compass and preferably a topo map when headed out into the wilds. In these modern, hi-tech times many people carry a GPS unit, or have GPS on their smart phones. I wish I could tell you more about these but you're talking to a guy who only got his first cell phone last year when forced to do so by his loving wife. I've always held to the belief that simpler is better and more reliable. An old time magnetic compass doesn't have any batteries to go out, it keeps working after you've fallen into a stream, and you have to bang it pretty hard to break it. A compass alone is not nearly as useful as a compass used in conjunction with a map, but a compass can keep you going in a straight course which is very hard to do otherwise.
One technique that you can use to keep yourself found with only a compass is called backstopping. Backstopping cannot be used in every instance but it can be used in many. Here's how it works.
BACKSTOPPING WITHOUT A MAP
Let's say that you are going hiking in an area that you are unfamiliar with. All you have is a compass; no map of the area other than the road map or GPS in your car that you used to get to the area. You arrive at your take off point, say a road-side parking area, and prepare to head out into the woods. Look at your road map or the GPS screen in your car and see if the road continues in a fairly straight line in both directions from where you are standing. If it does, the road can serve as your backstop. Let's say that the road runs pretty much North and South, and you are going to be hiking in an area that is east of the road. Take a compass reading to verify that you are heading out on a course of, in this case, 90º. If you become lost or disoriented on your hike, you can follow a compass course of 270º and you will eventually hit your backstop. This method has its drawbacks. When you do hit your backstop, you may not know whether you are north or south of the place where your car is parked; but you're still better off than you would be wandering around in the woods. Railroad lines, utility lines, and pipelines all make good backstops. They usually follow a straighter and longer course than the average back-country road.
BACKSTOPPING WITH A MAP
Let's take the same scenario as above and assume that you do have a topo map with you. You hike for several hours and decide it's time to head back to the car. You orient your map and take bearings on a couple of landmarks to fix your position. Now you can set a compass course straight for your vehicle. So you follow your course, hit the road, and there's no vehicle. Now you don't know if you parked farther to the South or to more to the North of where you came out onto the road. We've all been there. There's no way to follow a compass course with that much accuracy over broken ground. Here's something you can do to help minimize this problem. Set a course that will deliberately miss your target either to the North or to the South. If you haven't gone very far into the woods, you may want to aim for a point, say, half-a-mile north of your vehicle. When you hit your backstop you know that your vehicle is going to be to the south. The farther away from your target you are, the farther North or South your point of aim should be. This will help guarantee that variations in your course will not put you on the wrong side of your target.