My issue has been solved. I am sorry to anyone whose time I had wasted but I had another function that called that createSession
one. I didn't realize it because it was so long ago that I put it in there and I honestly don't know why I did in the first place. Simply a case of bad programming practices.
Please let me know if I should just delete this question. Otherwise thanks to everyone who contributed.