updated with less unnecessary checks. Also incorperated my Cookie mosnter stealing your cookie idea. Tested and works