in reply to setting cookies
You can't set and fetch the same cookie in the same request. Unless you've previously set the cookies correctly (and I don't believe you have, because I think the error message will hit the browser before the headers, though I could be wrong about this if you're using a weird HTTP server I've not seen before but take it as a rule of thumb anyway), $cookies{ID} will be empty.
Even if you have set the cookie successfully, you have no control over what the client does with it. You have to check that you've retrieved a cookie successfully and you have to be ready to do something sensible if you haven't.
if (exists $cookies{ID}) { my $id = $cookies{ID}->value(); # do something here }
|
|---|