When Shira Newman flies home from Tel Aviv this summer, she won’t be worried about long lines at the airport or short tempers on the plane. Instead, she’ll be concerned about her Samsung Galaxy S7 phone — specifically, the information on it.

Newman, a stay-at-home mom from Portland, Oregon, has heard about Sidd Bikkannavar, the American citizen who was asked for his phone and his passcode when he entered the country this year. She knows U.S. Customs and Border Protection (CBP) reserves the right to search laptops and phones and even to review social media profiles, and she doesn’t want to be next.

“No one has the right to take my phone,” Newman says. “Is there a way to protect my privacy?”

It helps to know the likelihood of having a digital pat-down. Searches of your electronics at the border, at least the kind experienced by Bikkannavar, appear to be rare. Of the more than 390.6 million arriving passengers in the United States during fiscal year 2016, the number of travellers whose electronic devices were searched was 19,033, or 0.005 per cent, up from 0.002 per cent in the previous year.

Her agency, which is responsible for ensuring the safety and admissibility of the goods and people entering the United States, exercises its border-search authority in accordance with its statutory and constitutional authority. And, notes Gabris, no court has ruled that the border search of electronic devices requires a warrant — at least not yet.

Scott Olson/Getty Images

In a vast majority of electronics searches, agents are not interested in your Facebook friends, experts say.

“Most customs or border-protection agencies are looking to verify that the device functions normally, and is not being used to transport illicit materials or possibly explosives,” says Nathan Wenzler, chief security strategist at AsTech Consulting. “Customarily, they’ll ask an individual to power it on to demonstrate this.”

Depending on the country you’re arriving from and your nationality, customs agents may go a step further, Wenzler says. They could ask arriving passengers to log on to their computers and verify that the device functions normally, a request that might be seen as intrusive, if not inappropriate.

So how do you protect your electronics when you’re passing through customs?

Let’s start with what you shouldn’t do, which is to check the electronics in your luggage. When ramp workers pilfer your luggage, they’re looking for valuables such as electronics. To make matters worse, airlines often have language in their contracts of carriage — the legal agreements between you and the airline — that limits their liability. Checking your iPad isn’t a workaround. Instead, it exposes you to a different kind of trouble.

One popular strategy among privacy-conscious air travellers is the backup-and-wipe maneuver. “Make sure you are backing everything up in the cloud,” explains James Carder, a vice president of LogRhythm Labs, a computer security company. He backs up his iPhone and iPad to the cloud before leaving. Then, if he gets to the border and sees agents checking devices, he deletes all the data on them. “When I get to the other side, I restore the device with all my data in it,” he explains.

If backing up to the cloud is impractical, you can still make your device more difficult to access. One easy strategy: Enable PIN codes on your smartphone, tablet, or laptops. That forces a nosy customs agent to ask for your code before accessing your data.

“Log out of your apps, too,” says Yaron Baitch, a senior director at LastPass, a password-management application. To do that, launch each app and log out of any active sessions. Don’t forget to uncheck the “remember me” option on your apps. These steps can be enough to deter an unwarranted search of your electronics, but they don’t guarantee it.

Protecting your data should be your highest priority. To do that, consider swapping out the hard drive on your laptop for a clean one, advises Craig Smith, an attorney who specializes in intellectual-property issues for the Cambridge, Mass., law firm Lando & Anastasi, LLP.

“The goal is to limit the amount of data you carry during your travels to mitigate the risk of disclosure,” he notes. If you can’t remove the hard drive, consider encrypting it and protecting it with a strong password. Again, this creates an obstacle for a customs agent that could be enough to deter a more detailed search.

But there’s only one certain way to ensure that a federal employee doesn’t see your Twitter account. “I have been advising all of my clients to not carry electronics with saved data on them,” says immigration attorney Renata Castro. She admits that’s a little extreme, but says it’s the only way to ensure you get across the border without giving up your privacy. And for her clients, that could literally be a life-or-death matter, especially for those who might want to file for asylum in the United States. Erase your phones and laptops before you travel, or leave them at home. “There’s no constitutional way to protect information at the border,” she adds.

Better yet, leave your laptop at home when you travel this summer, says Jeremiah Grossman, chief of security strategy at SentinelOne. “This might actually be a welcome option,” he says. “Rather than feel attached to a laptop, consider going device-free.”

Newman, the concerned traveller from Portland, can add a stronger password, upload her data to the cloud or be prepared to wipe her device at the border. But the only certain way of maintaining her privacy is to leave her phone at home.