What is prescribed for the Muslim is to encourage those he meets to adhere to the truth in word and deed, and to be patient in doing that and calling people to it, as Allah, may He be exalted, says (interpretation of the meaning):
“By Al-Asr (the time).
Verily! Man is in loss,
Except those who believe (in Islamic Monotheism) and do righteous good deeds, and recommend one another to the truth (i.e. order one another to perform all kinds of good deeds (Al-Maroof )which Allah has ordained, and abstain from all kinds of sins and evil deeds (Al-Munkar )which Allah has forbidden), and recommend one another to patience (for the sufferings, harms, and injuries which one may encounter in Allah’s Cause during preaching His religion of Islamic Monotheism or Jihad, etc.).”
It was narrated that Abu Madeenah ad-Daarimi, who was a Companion, said: When two men among the Companions of the Prophet (blessings and peace of Allah be upon him) met, they would not separate until one of them recited to the other, “By Al-Asr (the time).Verily! Man is in loss,” then one of them would say salaam to the other.
Narrated by at-Tabaraani in al-Awsat, 5124; al-Bayhaqi in Shu‘ab al-Eemaan, 8693. al-Haythami said in al-Majma‘, 10/233: Its men are the men of as-Saheeh.
Bilaal ibn Sa‘d (may Allah have mercy on him) said:
A brother of yours who reminds you of Allah every time he meets you is better for you than a brother who puts a dinar in your hand every time he meets you.
End quote from Hilyat al-Awliya’, 5/225
With regard to asking about the state of someone’s heart or the level of his faith, there is the fear that this may lead one to self praise or it may cause the one who is asking the question to show off in front of people, as if he has a believing heart and fears Allah all the time. Or it may imply that the one who is asked is falling short in his duty towards Allah, may He be exalted, or it may make the one who is asked to try to say good things about himself to avoid embarrassment, and other negative consequences. Perhaps it is because of that we did not find such questions mentioned in reports about the ways and sayings of the early generations; we do not know that they used to ask about such matters.
With regard to the well-known hadeeth from al-Haarith ibn Maalik al-Ansaari, which says that he passed by the Messenger of Allah (blessings and peace of Allah be upon him), who said to him: “How are you this morning, O Haarith?” And he said: I am a true believer this morning, and the Prophet (blessings and peace of Allah be upon him) said: “Watch what you say, for everything has a reality, so what is the reality of your faith?” He said: I have lost interest in this world, and I spend my night in prayer because of that, and I spend my day thirsty (i.e., fasting), and it is as if I can see the throne of my Lord, and it is as if I can see the people of Paradise visiting one another in it, and it is as if I can see the people of Hell screaming in it. The Prophet (blessings and peace of Allah be upon him) said: “O Haarith, you have realised, so remain steadfast”, three times… This hadeeth was narrated by at-Tabaraani in al-Mu‘jam al-Kabeer, 3/266; it is a da‘eef (weak) hadeeth and is not saheeh (sound).
Al-‘Aqeeli (may Allah have mercy on him) said: This hadeeth does not have an isnaad that can be proven.
End quote from ad-Du‘afa’ al-Kabeer, 4/455
Ibn Taymiyah (may Allah have mercy on him) said:
It has an isnaad, but this isnaad is da‘eef and cannot be proven.
End quote from al-Istiqaamah, 1/194
Based on that, we should refrain from asking such questions that may lead to some negative consequences; the Muslim should only ask how his brother is in general terms.
So he should say to him: How are you? or, How are you this morning? And so on.
Something like that has been narrated from the Prophet (blessings and peace of Allah be upon him).
It was narrated that ‘Aa’ishah (may Allah be pleased with her) said: An old woman came to the Prophet (blessings and peace of Allah be upon him) when he was in my house and the Messenger of Allah (blessings and peace of Allah be upon him) said to her: Who are you? She said: I am Jaththaamah al-Muzaniyyah. He said: Rather you are Hassaanah al-Muzaniyyah; how have you been since we last saw you? She said: We are well, may my father and mother be sacrificed for you, O Messenger of Allah. When she left I said: O Messenger of Allah, all of this welcome for this old woman? He said: She used to visit us at the time of Khadeejah, and loyalty is part of faith.”
Narrated by al-Haakim in al-Mustadrak, 1/62; classed as hasan by al-Albaani in as-Silsilah as-Saheehah, no. 216
And Allah knows best.