They can stop you walking in or they can order you to leave via trespass law, but any claim to a right to detain and/or search you is meaningless. Their authority is limited to cancelling your membership and banning you from the premises as trespass should you refuse.Costco claims it as a condition of membership and I'm not aware that it has been successfully challenged.
