When entering the mosque, put forward the right foot and recite this supplication:
بِسْمِ ٱللَّهِ ٱللَّهُمَّ ٱفْتَحْ لِي أَبْوَابَ رَحْمَتِكَ
“In the name of Allah. O Allah! Open for me the doors of Your mercy.”
Women should sit in the place designated for them, calmly and with tranquility. However, they should not sit in the mosque without first praying two rak’ahs of Tahiyyat al-Masjid (the greeting of the mosque, after entering the mosque), because the Messenger of Allah ﷺ said:
إذا دخل أحدكم المسجد فلا يجلس حتى يصلي ركعتين
“When any of you enters the mosque, he should not sit until he has prayed two rak’ahs.”
However, if the sun is rising or setting, they should sit and not pray, because the Messenger of Allah ﷺ forbade praying at these times. In case of need, if there is no fear of any fitnah (trial) or mischief, a woman may even spend the night in the mosque.
When leaving the mosque, put forward the left foot and recite this supplication:
ٱللَّهُمَّ إِنِّي أَسْأَلُكَ مِنْ فَضْلِكَ
“O Allah! I ask You for Your bounty.”