fix sigfault in cookie functions