When are two diagonal matrices congruent?

This is probably a question that does not admit a simple answer. However, I’d like to know whether there exist criteria that determine when two diagonal matrices are congruent. I have the suspicion that, if such criteria exist, they depend strongly from the base field. In fact, over a quadratically closed field two diagonal matrices are congruent iff they have the same rank and over real closed fields Sylvester theorem answers completely the question. But over other fields?

By Witt decomposition, we can restrict ourselves to consider only the case in which $A$ and $B$ are anisotropic. Hence the question is:

Let $\mathbb{K}$ be a field and let $A = \mathrm{diag}(a_1, \dots, a_n)$ and $B = \mathrm{diag}(b_1,\dots,b_n)$ be two diagonal matrices over the field $\mathbb{K}$ such that $^t x A x \neq 0$ and $^t x B x \neq 0$ for all $x \in \mathbb{K}^n \setminus \{ 0 \}$. (In particular $a_i \neq 0$ and $b_i \neq 0$). What are necessary or sufficient conditions to have that $A$ and $B$ are congruent?

Solutions Collecting From Web of "When are two diagonal matrices congruent?"