It’s easily done, especially if you are tired or at the end of the day.
Here’s a tip I learned from a teacher many years ago.
Make sure you are sitting upright. Place one (say your right) elbow in your left hand so your right arm is vertical.
If you start to fall asleep and lose consciousnesses, your right arm will start to slowly move downwards…then pick up speed as it heads towards the floor!
As soon as you become aware of any slight movement, bring your attention back to your mediation practice.
Now you can stay relaxed, alert and aware.