The bill states that accessing without a warrant electronic equipment, the contents of an online account, or information about someone’s online life is a violation of the Fourth Amendment. Border agents are not allowed to deny someone entry for refusing to provide a password or unlock their information, a protection the bill clarifies. It does include an exception for emergency situations.

The government has historically claimed it has broad authority to conduct searches at the border, to seize devices, and to copy their contents. Travelers have reported being detained for hours while agents try to convince them to surrender their social media accounts and demand that they unlock their phones; they are also routinely asked about their political or religious beliefs and pressured to become informants . So far, court challenges to these practices have been unsuccessful, but the new legislation cites a 2014 Supreme Court decision that found that police need additional authority to search the cellphone of someone who has been arrested, recognizing that such devices hold massive amounts of private information.

The bill makes it illegal to access the contents of a device belonging to a U.S. citizen or permanent resident without probable cause and a warrant, and specifies that border agents can’t hold people for more than four hours to try to get them to unlock their phone or give up their data. It was simultaneously introduced on Tuesday in the Senate by Ron Wyden of Oregon and Rand Paul of Kentucky and in the House by Jared Polis of Colorado and Blake Farenthold of Texas. Wyden and Polis are Democrats while their co-sponsors are Republicans.

Four members of Congress have introduced legislation that would require border agents to get a warrant to search through someone’s cellphone or laptop, bringing privacy rights at ports of entry closer to those that courts have recognized for the rest of the country.

“Whether you are at home, walking down the street, or at the border, we must make it perfectly clear that our Fourth Amendment protections extend regardless of location,” Representative Polis said in a statement. “This bill is overdue, and I am glad we can come together in a bicameral, bipartisan manner to ensure that Customs and Border Patrol agents don’t continue to violate essential privacy safeguards.”

Neema Singh Giuliani, legislative counsel at the American Civil Liberties Union, said that “if the bill is passed it would effectively prohibit CBP from doing what it does now, which is searching and seizing devices of U.S. persons.” She added that the bill has “good language to address cases where people have supposedly consented to searches, requiring documentation that they actually did consent.”

The number of cell phone searches at points of entry to the United States has risen dramatically in the past two years, jumping from 5,000 in 2015 to 25,000 in 2016. There were 5,000 in February of 2017 alone. In February, Wyden asked the Department of Homeland Security to send him information on CBP searches, including how often travelers are asked to unlock their phones or laptops, or turn over social media passwords; in his letter, he said he was concerned that CBP was “short-circuiting… vital checks and balances” with “indiscriminate” searches. He said he expected business travelers to start using burner devices when traveling — and indeed, since Trump took office, guides on how to secure your data when crossing borders have proliferated. It’s also not clear how widely the information that the CBP collects may be shared with other law enforcement or intelligence agencies.

The bill does not add any protections for travelers to the United States who are not citizens or permanent residents. Late last year, the CBP began asking travelers from certain countries for their social media handles, and the Trump administration has indicated it will take this much farther. The Wall Street Journal reported Tuesday that the administration’s plans for “extreme vetting” of visa applicants would include asking them to turn over their cellphones so U.S. authorities could look at their contacts, and to provide social media account names and passwords. The changes would apply even to travelers coming on short trips and from Europe and other countries covered by the visa waiver program. The State Department has also reportedly instituted “mandatory social media checks” for any visa applicant that has spent time in territory controlled by ISIS.

Demands for social media passwords at the U.S. border constitute “a direct assault on fundamental rights” of travelers and expose their social networks to “unjusitifed scrutiny,” a coalition of 131 groups, including entities focused on civil liberties, human rights, activism, and trade, declared in a joint statement last month. The statement added that the social media scans will discourage travel for both business and pleasure.