GENEVA — When it comes to cooking fresh lobster, the Swiss are now saying: We feel your pain.

A law goes into effect March 1 that bans the common cooking method of tossing a live lobster into a big pot of boiling water, quickly killing the tasty crustacean. That practice is being outlawed because the Swiss say it’s cruel and lobsters can sense pain.

The first national legislation of its kind in the world calls for a more humane death for lobsters, by “rendering them unconscious” before plunging them into scalding water. Two methods are recommended: Electrocution or sedating the lobster by dipping it into salt water and then thrusting a knife into its brain.

The same law also gives domestic pets further protections, such as dogs can no longer be punished for barking.

The measure is part of the broad principle of “animal dignity” enshrined in Switzerland’s constitution, the only country to have such a provision. The constitution already protects how various species must be treated and specifies that animals need socialization.

That means cats must have a daily visual contact with other felines, and hamsters or guinea pigs must be kept in pairs. And anyone who flushes a pet goldfish down the toilet is breaking the law.

The new lobster legislation that boils down to a pain-free death was driven by research, including a study by Queen’s University in Belfast that found crustaceans are sentient creatures.

“These studies show that lobsters, like other animals, experience pain and distress,” said Stefan Kunfermann, a spokesman for the Federal Office of Food Safety and Veterinary Affairs.

Although lobster consumption in this land-locked country is “negligible,” the parliament had tried to ban the import of all live lobsters to prevent them from an agonizing death at the hands of Swiss restaurant cooks, Kunfermann said.

That drastic measure against imports would violate international trade agreements, so authorities instead issued new rules on how to make the lobsters’ demise as painless as possible.

The law also stipulates that lobsters must be transported to their final Swiss destination in their natural environment — seawater — rather than on ice.

The government vows that offenders will not slip through the net. State officials will be responsible for enforcement, and Kunfermann said offenders could land in a lot of hot water, with sentences of up to three years in prison.

Animal rights activists applaud the new lobster law and call for more action.

“While this may end one of the cruelest methods of killing these fascinating beings in Switzerland, there are no laws protecting them from being boiled alive in other countries — including the U.S.,” People for the Ethical Treatment of Animals (PETA) said on its website.

“Globally, Switzerland is in the forefront of animal welfare legislation,” said Antoine Goetschel, an attorney and founder of the Zurich-based Global Animal Law Association.

In 2010, Goetschel represented in court a 22-pound pike that he said suffered when a local fisherman roughly yanked it for 10 minutes before pulling it from icy Lake Zurich.

The fisherman was eventually acquitted, but Goetschel spearheaded a national referendum that same year to grant animals the constitutional right to be represented by lawyers in court. The proposal was rejected by 70% of the voters.

Not everyone is happy with the regulation. Chef René Widmer, founder of Prorest Culinary School in the town of Rafz, complained to Blick newspaper that the new law is useless.

“I always turned the lobster upside down before throwing it into the boiling water — then it dies within seconds,” he said.