It is not permitted to study in a mixed setting with female students in one place or in one school or on one bench. This is one of the greatest causes of fitnah (temptation) and it is not permissible for a male or female student to take part in this, because of the fitnah involved. The Muslim should not shake hands with a non-mahram female, even if she holds out her hand for him to shake, and he should tell her that shaking hands with a non-mahram man is not permitted, because the Prophet (peace and blessings of Allaah be upon him) said, when accepting the allegiance (bay’ah) of women: “I do not shake hands with women.” And it was narrated that ‘Aa’ishah (may Allaah be pleased with her) said: “By Allaah, the hand of the Messenger of Allaah (peace and blessings of Allaah be upon him) never touched the hand of any (non-mahram) woman; he used to accept their allegiance in words only.” And Allaah says (interpretation of the meaning):
“Indeed in the Messenger of Allaah (Muhammad) you have a good example to follow for him who hopes for (the Meeting with) Allaah and the Last Day, and remembers Allaah much”
For a woman to shake hands with someone who is not her mahram is something that may lead to temptation for both parties, so it must be avoided.
There is nothing wrong with the shar’i greeting of salaam in which there is no fitnah and no shaking hands, and which does not give rise to doubts and does not involve any softness in speech, and in which hijaab is observed and there is no being alone with a member of the opposite sex, because Allaah says (interpretation of the meaning):
“O wives of the Prophet! You are not like any other women. If you keep your duty (to Allaah), then be not soft in speech, lest he in whose heart is a disease (of hypocrisy, or evil desire for adultery) should be moved with desire, but speak in an honourable manner”
At the time of the Prophet (peace and blessings of Allaah be upon him), the women used to greet him and ask him questions concerning things they did not understand, and the women also used to ask the companions of the Messenger of Allaah (peace and blessings of Allaah be upon him) concerning things they did not understand.
With regard to a woman shaking hands with other women, or shaking hands with men who are her mahrams, such as her brothers, uncles, etc., there is nothing wrong with that.