Facebook agreed to pay $90 million to settle a decade-old privacy lawsuit accusing it of tracking users’ Internet activity even after they logged out of the social media website.

A proposed preliminary settlement was filed on Monday night with the U.S. District Court in San Jose, Calif., and requires a judge’s approval. The accord also requires Facebook to delete data it collected improperly.

Users accused the Meta Platforms Inc FB.O unit of violating federal and state privacy and wiretapping laws by using plug-ins to store cookies that tracked when they visited outside websites containing Facebook “like” buttons.

Facebook then allegedly compiled users’ browsing histories into profiles that it sold to advertisers.

The case had been dismissed in June 2017 but was revived in April 2020 by a federal appeals court, which said users could try to prove that the Menlo Park, Calif.-based company profited unjustly and violated their privacy.

Facebook’s subsequent effort to persuade the U.S. Supreme Court to take up the case was unsuccessful.

The company denied wrongdoing but settled to avoid the costs and risks of a trial, according to settlement papers.

Settling “is in the best interest of our community and our shareholders, and we’re glad to move past this issue,” Meta spokesman Drew Pusateri said in an email.

The settlement covers Facebook users in the United States who between April 22, 2010 and Sept. 26, 2011 visited non-Facebook websites that displayed Facebook’s “like” button.

Lawyers for the plaintiffs plan to seek legal fees of up to $26.1 million, or 29 percent, from the settlement fund. The lawsuit began in February 2012.

Facebook has faced other privacy complaints.

In July 2019, it agreed to bolster privacy safeguards in a U.S. Federal Trade Commission settlement that also included a $5 billion fine.

On Monday, Texas’ attorney general sued Meta, claiming it collected facial recognition data without users’ permission.

The case is In re: Facebook Internet Tracking Litigation, U.S. District Court, Northern District of California, No. 12-md-02314.

(Reporting by Jonathan Stempel in New York; Additional reporting by Nate Raymond; Editing by David Holmes)