Every such city or town shall have the same right, power and authority, by and through its properly constituted officers and courts, to commit prisoners to such city jail, and to confine therein persons apprehended for offenses against the laws of such city or town, as it had with reference to the jail specified in its special charter.