IAAL :)
"Generally speaking, it's illegal to detain someone from leaving without probable cause of a crime.
(In contrast, Costco is empowered to do so via their membership agreement.)"
This is commonly thought but not quite right, either on facts, or on law.
First, people cite a membership agreement.
Let's take a look:
https://www.costco.com/wcsstore/CostcoUSBCCatalogAssetStore/...
https://www.costco.com/member-privileges-conditions.html
Nothing there.
Maybe it's elsewhere. Can't easily be found (not good for Costco!)
It does say they can adopt rules at any time.
But false imprisonment requires voluntary consent, which is knowing. So that would not help them.
Besides that, false imprisonment, in most states, is both a felony and a tort :)
The answer to the question "are you likely to be able to sue costco successfully for trying to check your receipt when you don't want them to" - no, unless you revoke consent and they don't revoke your membership and kick you off the property :)
The answer to the question "can they legally detain you" - also no if you revoke consent (and the first person to say something about the 4th amendment here loses, since we are talking about private actors).
Voluntary consent is definitely a valid defense to false imprisonment.
However the idea that consent in the membership agreement overrides anything that later happens is, at best, laughable.
Imagine the membership agreement says "you unconditionally consent to costco locking you up in the backroom until they get bored".
Do you think I don't have a false imprisonment claim, if, when they try to do so, i say "I do not consent to this", and they do it anyway?
How is that voluntary consent? Even if i did consent, i clearly and unequivocally revoked it. Maybe i breached a contract. Irrelevant, however. Remember, it's both a tort and a crime. Even if they have an argument about the tort (they don't really), they don't about the crime.
There is plenty of precedent on revocation of consent all the way up the Supreme Court (United States v. Drayton, etc).
Saying "no" to a receipt checker and walking away almost certainly counts as proper consent revocation.
Now Costco certainly has the right to revoke my membership and remove me from their property. But they can't certainly can't detain me though once i've revoked consent. It even may have a reasonable argument that the first time it tries to detain me, it was within the consent (depends on what happens in the above story).
The second i revoke my consent by saying no, sorry, it's clearly false imprisonment (in states that don't have a shopkeepers privilege).