Anyone who illegally dumps the kind of infectious medical wastes that turned 1988 into a nightmare for beach-goers faces longer jail terms and stiffer fines in New York under legislation signed into law. Gov. Mario M. Cuomo said the syringes, blood vials and other medical debris that washed ashore this summer “threaten the livelihood of thousands who work at our beaches and the enjoyment of the millions of New Yorkers who use the beaches for recreation.” Several popular beaches were temporarily closed during the state’s hottest summer in decades when the debris came ashore. Under the bill approved by Cuomo, penalties of up to four years in prison and fines of up to $50,000 could be brought against people convicted of illegally disposing of so-called red bag medical wastes. The name refers to waste that is to be thrown out in specially marked containers.