It depends on the hotel. Larger hotels usually don't even try to control it, since it would require too much additional effort. Smaller hotels might allow visitors but require that they sign in and show identification. There may be restrictions on the hours for visiting, on the use of facilities, etc.