getCookie function, mark this as a single commit so that we can copy the function easily