Sens. John Kerry, D-Mass., and John McCain, R-Ariz., unveiled an online privacy bill Tuesday aimed at strengthening the protection of personal information that companies collect from consumers over the Internet.

The Commercial Privacy Bill of Rights Act of 2011 would require companies to collect personal data only if they receive affirmative consent, or an opt-in, from consumers. Under the bill, the companies would then offer consumers the option to opt out of having their data shared with third parties. 

The bill would also allow collection and sharing of personal information only by companies that do advertising or marketing.

"Right now there is no law protecting the information that what we share. Companies can harvest our personal information online and keep it for as long as they like," Kerry told reporters, emphasizing that the senators are not opposed to companies collecting information from consumers to target ads at them.

"But the data deluge is worrying at the same time," Kerry said. Companies can sell information "without asking permission or even letting you know that they're selling your own information. ... You shouldn't have to be a computer genius in order to be able to opt out of information sharing."

Yahoo, which already allows users to opt out of targeted advertising, offered cautious support for the bill.

"As a pioneer in protecting user privacy, Yahoo! Believes that Sens. Kerry and McCain have taken an important step in trying to establish industry-wide baseline protections for consumer privacy," Yahoo said in a statement to FoxNews.com. "While there certainly remain some fundamental issues to be worked out to make sure that this legislation protects the extraordinary breadth of free services for consumers made possible by online advertising, Yahoo! commends the hard work that Sens. Kerry and McCain have done thus far."

In recent years, the Federal Trade Commission has been under pressure from privacy advocates to crack down on companies that track users' Internet usage, saying that the practice poses risks to consumer privacy. After issuing a report late last year on Internet privacy that underscored highlighted dissatisfaction with the self-regulating efforts by companies, the agency began pushing Congress to introduce legislation.

The Obama administration gave its blessing to online privacy legislation for the first time last month. Lawrence Strickling, who oversees the telecom arm of the Commerce Department, told a Senate legislative committee that "ground rules" are needed to "promote innovative uses of information while respecting consumers' legitimate privacy interests."

He added that those privacy guidelines should avoid creating "an overly complicated regulatory environment."

McCain said their bill balances the business interests of companies and the privacy concerns of consumers.

"Our bill seeks to respect the ability of businesses to advertise, market and recruit new customers while also respecting consumer's personal information," McCain said. "Striking this balance was the hard part of our negotiations and our efforts to bring forth this legislation. "

This isn't the first online privacy bill introduced in this year's Congress. In February, Rep. Jackie Speier , D-Calif., unveiled her Do Not Track Me Online Act of 2011. Her bill would direct the Federal Trade Commission (FTC) to develop standards for a "Do Not Track" mechanism that would allow consumers to opt out of having their data used by third parties instead of relying on companies the way the Kerry-McCain bill does.

Her bill is under committee review.

Kerry said he and McCain didn't include the do-not-track feature because "it didn't seem to fit into our ability to get the balance between the consumer support and the industry support that we wanted to get."

Kerry added that if the opt-out clause is strong enough a do-not-track mechanism is not necessary.