I am creating cookie in first file and wants to update cookie value into second file. I am using following code to read and update the value of cookie. But it is not working.
my $new_value = 'modify';
my %cookies = fetch CGI::Cookie;
foreach (keys %cookies) {
### I want to change value of NewCookie
if($_ eq 'NewCookie') {
my $val_cookie = $cookies{'NewCookie'}->value;
warn "\n value of NewCookie =>" . $val_cookie;
$cookies{'NewCookie'}->value = $new_value; ###I don't know is it work or not
}
}
I am getting this error
“Can’t modify non-lvalue subroutine call at”
I think your problem is in this line of code:
$cookies{'NewCookie'}->value()is a method. You are trying to assign a value to a method. I am not that familiar with CGI::Cookie, but perhaps you need to change that line of code to look like this: