Hello
I am crumbling over perl cookies
I'm using CGI::Cookies
and am reading the perl documentation for CGI::Cookies at
I can set new cookies as follows:-
$cookie1 = new CGI::Cookie(-name=>$cookiename1,-value=>$defaultcookievalue1,-expires=>'+3M');
$cookie2 = new CGI::Cookie(-name=>$cookiename2,-value=>$defaultcookievalue2,-expires=>'+3M');
print header(-cookie=>[$cookie1,$cookie2]);
Easy great I've tried it and it works.
Now I have my cookies, I've learned how to fetch the cookies as follows:-
%mycookies = fetch CGI::Cookie;
I can extract the values like so:-
$mycookies{$cookiename1}->value();
Now I've fetched the value all I want to do is alter and save it
The documentation says do this:-
@new_value = $c->value(['a','b','c','d']);
and explains that it is updating the cookie and returning the updated value to the array
What is confusing me is the use of $c looking back up the documentation $c was used for
creating a NEW cookie with default values.
My cookie already exists and all I want to do is change it's value.
Do I have to read the cookie, delete it, manipulate the values i got from it, generate a new cookie with the same name and updated values and then save it?
I'm lost
Can anyone help before I crumble to dust?
just a simple example of updating the value of an exisiting cookie using CGI::Cookies would help me a lot
I am crumbling over perl cookies
I'm using CGI::Cookies
and am reading the perl documentation for CGI::Cookies at
I can set new cookies as follows:-
$cookie1 = new CGI::Cookie(-name=>$cookiename1,-value=>$defaultcookievalue1,-expires=>'+3M');
$cookie2 = new CGI::Cookie(-name=>$cookiename2,-value=>$defaultcookievalue2,-expires=>'+3M');
print header(-cookie=>[$cookie1,$cookie2]);
Easy great I've tried it and it works.
Now I have my cookies, I've learned how to fetch the cookies as follows:-
%mycookies = fetch CGI::Cookie;
I can extract the values like so:-
$mycookies{$cookiename1}->value();
Now I've fetched the value all I want to do is alter and save it
The documentation says do this:-
@new_value = $c->value(['a','b','c','d']);
and explains that it is updating the cookie and returning the updated value to the array
What is confusing me is the use of $c looking back up the documentation $c was used for
creating a NEW cookie with default values.
My cookie already exists and all I want to do is change it's value.
Do I have to read the cookie, delete it, manipulate the values i got from it, generate a new cookie with the same name and updated values and then save it?
I'm lost
Can anyone help before I crumble to dust?
just a simple example of updating the value of an exisiting cookie using CGI::Cookies would help me a lot