— Fifteen years ago, Sen. John McCain voted twice to impeach Bill Clinton, saying the president had “thwarted justice” by lying about his extramarital affair with a White House intern.

On Friday night, however, all that seemed far in the past. On stage at a philanthropic gathering of college students here, the Arizona Republican and the former Democratic president hammed it up like old buddies. They talked about the serious (Russia’s aggression in Ukraine) and the silly (tweets from reality star Nicole “Snooki” Polizzi), and they showered each other in high praise.

Introducing McCain on a panel at the Clinton Global Initiative University conference he is hosting at Arizona State University with his wife and daughter, Clinton called him “a good friend of Hillary’s and mine, although we permit him to deny it at election time.”

McCain in turn congratulated Clinton on two terms in office and credited him with intervening in Bosnia to end ethnic strife there. “I think you made the right decisions,” McCain told Clinton. And McCain, the 2008 GOP presidential nominee, thanked Clinton for “mentioning I ran for president.”

The bipartisan geniality underscored the close relationship McCain and Hillary Rodham Clinton developed when she was a senator, as well as the narrow daylight that exists between the two on foreign policy, from Iran to Syria to Ukraine.

The warmth also illustrated McCain’s recent political journey. Four years ago, McCain was running for reelection as an embattled incumbent struggling to prove his conservative bona fides and beat back a tea party challenger. The McCain of 2010 may not have so warmly welcomed the Clintons to Arizona nor shared a stage with them.

Yet here was McCain, explaining to Clinton his experiences with Twitter — a medium the former president called “a staggering instrument of potential.”

“Everyone has their experiences with Twitter and tweeting,” McCain said. When Congress passed the Affordable Care Act, he recalled, he received a tweet from someone named Snooki.

“I don’t know how familiar you are with Snooki, Mr. President,” McCain said, eliciting knowing laughter from Clinton.

McCain said the orange-skinned star of MTV’s “Jersey Shore” sent him a tweet complaining that the health-care law included a tax on tanning beds, to which McCain replied he would never tax her tanning bed.

Clinton smiled, quipped, “I’ll stay away from that,” and steered the panel to a conversation about encouraging more girls to pursue degrees in science, technology, engineering and math.

McCain spoke on a panel with Wikipedia founder Jimmy Wales, Saudi Arabian women’s rights activist Manal al-Sharif and Harvard University student Shree Bose. Clinton moderated.

Earlier, Hillary Clinton opened the conference of 1,200 student leaders by declaring, “We’re going to make sure that the millennial generation really is the participation generation.”

Although the three-day conference centers on altruism, current events entered into the discussions. Both Clintons voiced strong concern that Turkish Prime Minister Recep Tayyip Erdogan is attempting to limit access to Twitter, while Bill Clinton spoke numerous times about the conflict in Ukraine.

He said the protests in Ukraine that led to the overthrow of Viktor Yanukovych’s government were against political corruption and abuse of power, not Russian influences. Noting that his foundation does considerable work in Ukraine, Clinton said, “I’ve literally never met a Ukrainian who wanted to be on hateful terms with Russia.”

Clinton then asked McCain, a hawk regarded as one of his party’s leaders on foreign policy, how to best organize against the “hard power” that was “crushing life and liberty” in Ukraine as well as in Syria.

“We don’t always have to stand up with bombs and bullets, but we can stand up for them,” McCain said. “It is in our interest to see a world that is freer and more democratic.”

Referring to a conversation he had backstage earlier with Clinton about Russia’s president, McCain said, “Vladimir Putin is not a democrat. He’s an old KGB colonel, and Vladi­mir Putin wants to restore what was once the Russian empire.”

Clinton ended the discussion by asking McCain whether the old Washington axiom, “politics ends at the water’s edge,” meaning that one shouldn’t criticize the president while traveling overseas, holds true in today’s polarized political climate.

“Does that idea still have any power over people younger than we are, John?” Clinton asked.

“I believe it does,” McCain responded. “We still only have one president of the United States.”