fix Cookie not setting correctly first time starting the page