Fix bug in getCookie function