Sleeping pills are okay to take in moderation for up to a few weeks if you're having trouble sleeping.
But you should try taking the sleeping pills for a few nights and then go a few nights or at least a night without taking a sleeping pill.
If you're still unable to sleep then you might need to continue taking sleeping pills.
Sleeping pills though should be used as a last resort because long term sleeping pill use can lead to health issues and might actually make your insomnia worse.
An alternative to sleeping pills is to eat some cherries or drink some cherry juice before bed as the cherries and cherry juice naturally contain melatonin which is a natural sleep hormone.
Not getting sleep though is more harmful to your health than taking sleeping pills would ever be though.