When a person charged with a felony is supposed by the magistrate before whom he is brought to have upon his person a dangerous weapon or anything which may be used as evidence of the commission of the offense, the magistrate may direct him to be searched in his presence, and the weapon or other thing to be retained, subject to his order or the order of the court in which the defendant may be tried.
R.L.1910, § 6079.