Divorcing amicably would “certainly be better for your son,” a judge told former Democratic congressman Anthony Weiner and Hillary Clinton aide Huma Abedin on Wednesday at the couple’s first divorce court hearing.

Weiner, who is awaiting prison sentencing later this month on a federal obscenity charge involving a 15-year-old girl, and Abedin walked into the courtroom together, sat together and chatted during breaks in the proceedings in Manhattan.

The judge, Michael Katz, said the couple appeared to be on track to “resolve this amicably” and said he is seeking to “hopefully help you work something out that works for your family” and “save you a lot of stress.”

Abedin’s lawyer, Amy Donehower of Manhattan, asked the judge to keep the case, filed as Anonymous v. Anonymous, confidential.

“Because there is a child involved, we’d like to keep the proceedings secret to the extent your honor will allow,” she said.

The judge said he would rule on the secrecy motions at a later date, but allowed the media to photograph the proceedings, citing the American presumption of open courts.

Abedin, Clinton wrote in her new book, broke into tears when learning about her sexting husband’s latest troubles involving photographs of an underage teen, and how it implicated Clinton’s private email server.

Neither answered reporters’ shouted questions in the courthouse corridor.

The divorce hearing came almost four years to the date after Weiner ranked in nearly last place while running for mayor in 2013, in a comeback bid after his resignation from congress over sexting in 2011. The disclosure that Abedin was pregnant came after the revelation that Weiner had kept up his habit of sexting with strangers, which felled his mayoral aspirations. Their son, Jordan, was born months later.

Get the latest news and more great videos at NewsdayTV Credit: Newsday

Latest on the weather ... Scourge of street takeovers ... Riders unhappy with LIRR ... Top high school football talent ... Get the latest news and more great videos at NewsdayTV

Get the latest news and more great videos at NewsdayTV Credit: Newsday

Latest on the weather ... Scourge of street takeovers ... Riders unhappy with LIRR ... Top high school football talent ... Get the latest news and more great videos at NewsdayTV

FLASH SALE

$1 FOR ONE YEAR

Unlimited Digital Access

SUBSCRIBE NOW >>Cancel anytime - new subscribers only