As @Becket says, people react different. My brother takes Lunesta with no problem.
Ambien was terrible for me. Never slept the entire night. Then I began to forget things. Once was on a work call, began a new subject when I was stopped, and told I had already discussed it. Still don't remember. Never took it since.
On a later visit to my doctor, told him still wasn't sleeping well, and why I stopped Ambien. He wrote a Rx for Temazepam. Had it filled, but never did take any. On occasion in the past, I've taken 0.25 mg Xanax if I can't sleep, but haven't for over a year.
These days sleep very well. Meds have changed over the years, and new ones added. A couple years ago, began 25 mcg Synthroid for thyroid due to TSH levels. Not sure if connected, but I feel much better since being on it.
Could be insomnia is a result of another underlying health issue.