\documentclass{article}
\usepackage{ifthen}
\usepackage{nameref}

\begin{document}

\newcommand*{\printRef}[1]{%
  \par
  \noindent
  #1:
  [\getrefbykeydefault{#1}{}{default}]
  [\getrefbykeydefault{#1}{page}{default}]
  [\getrefbykeydefault{#1}{name}{default}]
  [\getrefbykeydefault{#1}{anchor}{default}]
  [\getrefbykeydefault{#1}{url}{default}]
  \par
}
\printRef{A}
\printRef{B}
\printRef{C}

Test pageref(A) ?\ pageref(B) =
\ifthenelse{\equal{\pageref{A}}{\pageref{B}}}%%
{EQUAL}{DIFFERENT}

Test pageref(A) ?\ pageref(C) =
\ifthenelse{\equal{\pageref{A}}{\pageref{C}}}%%
{EQUAL}{DIFFERENT}

\section{Section A}\label{A}

\section{Section B}\label{B}%
\clearpage
\section{Section C}\label{C}
\end{document}
