Redo cookie code which dissapeared for some strange reason