Can they search my phone?

Updated 2107 GMT (0507 HKT) February 16, 2017

(CNN)If you're entering or returning to the US soon -- even if you're a US citizen -- you may be confused about your legal rights in the wake of President Trump's contested travel ban.

Can officers detain you at airports or other border checkpoints? Can they scroll through your phone? What happens if you say no?
To learn the answers to these and other questions, we spoke to three experts in immigration and privacy law: Danielle Rizzo and Leslie Holman of the American Immigration Lawyers Association, and Nathan Freed Wessler, a staff attorney with the ACLU.

Can I be stopped or searched at the border?

Yes. It doesn't matter if you're an American citizen, a green card holder or a visa holder, Customs and Border Protection (CBP) officers can stop you or take you to secondary inspection. This might happen because officers need more information about you or your immigration status to decide whether you should be allowed into the country. It could also be a random search.
According to Holman, even if you have a visa to enter the United States, CBP agents are ultimately deciding your "admissibility" into the United States.
A Customs and Border Protection officer checks IDs as people enter the US from Mexico in San Ysidro, California.

Do I have the same legal rights at the border that I would elsewhere?

No. The Fourth Amendment, which protects people from searches and seizures without probable cause of a crime being committed, doesn't apply in the same way at the border, Rizzo said.
According to Holman, probable cause and reasonable suspicion are not needed to search people -- Americans or foreign visitors -- at the border.

Am I allowed to speak with a lawyer?

It depends.
If you're a US citizen:
According to the ACLU, US citizens are allowed to request a lawyer be present for any questioning.
If you're a permanent resident or other foreign national with a visa:
If you're not American you generally don't have the right to an attorney unless you have been charged with a criminal offense or the questions relate to something other than your immigration status, Rizzo says.
Once the questioning goes past the basics -- like where you traveled or what you're bringing into the country with you -- to things like your political beliefs or the contents of your electronic devices, Wessler believes that all travelers, including non-citizens, have the right to counsel.

Can CBP officers take my green card away and not allow me back in the country?

No. Officers at the border cannot make you sign a form that would abandon your permanent resident status.
According to Rizzo, in most cases (unless you've committed a serious crime and are being deported), legal permanent residents have a right to a hearing before an immigration judge. So you would be allowed back into the country to wait until that hearing.
An air traveler is cleared by a Customs and Border Protection Officer at Dulles International Airport outside Washington.

Can my things be searched?

Yes, all people and their luggage and belongings entering the country are subject to search.

What if I bring prohibited or restricted items with me?

You will be asked to declare what items you're bringing into the country. If you have prohibited items, such as fruit that could carry pests or diseases, they will be confiscated and destroyed<