To add to this...
In MA it's illegal to do so in general and een if you are home it's illegal to store a weapon with ammo in it's magazine be it inserted within or near a gun. Also ammunition may not be stored unsecured. The only allownace for as much is if the weapon and ammunition is within direct control (not access) of the appropriately licensed owner or user.
Bed stand storage and gun behind the door stroage/stowage is expressly not allowed and even if you were to have a break in and use it properly to ones defense one would face charges of illegal storage of a firearm. This scenario occurred to a guy here in WMass last year just before I moved here.
Other states are less stupid...err I mean specific about in the home firearm storage, check your own local and state laws to be sure.
Here in MA the advised work around toward this is to keep a revolver for home defense and to store ammo within a speedloader which as per current law is not consdered to be a magazine.
I installed Springfield Armory 'Integrated Locking System' (I.L.S.) mainspring housing disablers on all my 1911s just to stay within the latter of the law toward state safe strorage/stowage laws. Even then I can't use them in the event of a break in because ammo cannot be stored in a magazine and must be secured. :\
- Janq