switched order of print and set cookie statement