A woodworker would join two 2x4s at right angles with a variety of joints.
The 45 degree miter joint idea is weak and tough to get just right; I would dismiss it.
A half lap joint is fairly easy to execute and if the joint is well done with smooth flat surfaces touching, glue can give it lots of strength. A nail or screw can also pin it together; I would pre-drill for the pin so the wood does not split. http://en.wikipedia.org/wiki/Lap_joint
Superior to a half lap are finger joints or mortise and tenon. Both are probably beyond a non-woodworker's skills and this situation's needs.
House carpenters frequently butt join 2x4s and simply nail them together. The nail (or lag screw you suggest) does not really grip the second piece very well, but this application will have no stresses in that direction and you should be all right (which is why Diana's suggestion of not attaching the two boards at all is not too far off).