The second amendment protects this right from federal infringement only. The states are free to infringe, guided only by their state constitution. In Illinois, cities are allowed to actually prohinit the ownership of guns within city limits. Chicago, Wilmette, Morton Grove -- all prohibit handguns.
-PJ
Just because they prohibit 'em doesn't mean the prohibition is legal. NJ just declared (to wit: recognized) residents have a 2nd Amendment right which the state cannot infringe.