improved prefix cookie handling