In an extract of her memoir, titled Hear Me Out, which was published in The Times, Harding wrote: “In December my doctor told me that the upcoming Christmas would probably be my last.
“I don’t want an exact prognosis. I don’t know why anyone would want that.
“Comfort and being as pain-free as possible is what’s important to me now.”
Harding said she is “trying to live and enjoy every second of my life, however long it might be”.
“I am having a glass of wine or two during all this, because it helps me relax,” she added.
“I’m sure some people might think that’s not a great idea, but I want to try to enjoy myself.
“I’m at a stage now where I don’t know how many months I have left.
“Who knows, maybe I’ll surprise everyone, but that’s how I’m looking at things.”
Harding also revealed she had sepsis while she was being treated for cancer in hospital.
She said she was put into an induced coma and was put on a ventilator.
“Even once I was off the ventilator, I couldn’t speak properly,” she said.
“All I could do was make noises that sounded like a chimpanzee trying to communicate.”
Harding said publicly revealing her diagnosis was “scary” but was also “the right thing to do”.
She said the support she has received has been “incredible”, adding: “I’ve been inundated with lovely messages from my fans. I’m grateful beyond words for that.”
The singer, who hadn’t posted on her social media accounts since the start of December, took to Instagram to update her fans.
She discussed her hospital treatments and confirmed that she had finished working on her autobiography.
She wrote: “I know I’m not really that present on here which I promise I’ll try to get a bit better at, as honestly it means the world to me when I come on and see all your well wishes. Thank you for the love and support, on bad days it helps me so much.
“So here’s a little update from me… Mum, the dogs and I had a really lovely but quiet Christmas together, which was different to my usual, but seemed a fitting way to end such a strange year.
“And since then, in between treatments and hospital visits I’ve managed to finish my book! I can’t believe I’ve actually gone and done it and it’s now at the printers!
“I’m so excited for it to come out: ‘I can’t rewrite history; all I can do is be honest and wear my heart on my sleeve. It’s really the only way I know. I want to show people the real me. Or perhaps remind them.
She said she called the book Hear Me Out because it’s the title of the song she wrote on the second Girls Aloud album and she’s “always loved it.”
“The lyrics have always meant a lot to me. It’s been lovely revisiting our songs, looking back over photos and writing down memories from my last 39 years,” she said.
“I really hope you might enjoy reading about them too.”
Ms Harding first shot to fame in 2002 after Girls Aloud topped the charts with Sound of the Underground.
After the group disbanded in 2013, the singer decided to focus on her acting career, having previously starred in St Trinians and BBC short film Freefall.
She released her debut solo single Threads in 2015, and scored a part as Joni Preston in Coronation Street that same year.
Ms Harding has also starred in a number of reality shows, including The Jump, Celebrity Masterchef and Celebrity Big Brother – the latter she won in 2017.