in reply to When are cookies created?

Just modify the hash returned from CGI::Cookie with the new cookie info. The cookie isn't updated in the browser until the current session is over.