in reply to When are cookies created?

The fetch function extracts cookies from the headers of the HTTP request that lead to your program being executed. Unless you sent out a cookie on a previous invocation of the program then the browser won't have a cookie to send in the headers.

So, no, you can't access the cookie during the same invocation of the program.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg