How to concatenate cookies - Perl
This is a discussion on How to concatenate cookies - Perl ; I would like to send multiple cookies in one variable, however the
code below just send one cookie:
for (my $j=0 ; $j<@custom_fields; $j++) {
$cookie_custom_fields .= $query->cookie(-domain=>$domainname,
-name=>"custom$j",
-value=>"$in_field[$j]" ) . ', ';
}
print $query->header(-cookie=>[$cookie_custom_fields]);...
-
How to concatenate cookies
I would like to send multiple cookies in one variable, however the
code below just send one cookie:
for (my $j=0 ; $j<@custom_fields; $j++) {
$cookie_custom_fields .= $query->cookie(-domain=>$domainname,
-name=>"custom$j",
-value=>"$in_field[$j]" ) . ', ';
}
print $query->header(-cookie=>[$cookie_custom_fields]);
-
Re: How to concatenate cookies
On 05/10/2007 09:41 PM, dr_phill123@yahoo.com wrote:
> I would like to send multiple cookies in one variable, however the
> code below just send one cookie:
>
> for (my $j=0 ; $j<@custom_fields; $j++) {
> $cookie_custom_fields .= $query->cookie(-domain=>$domainname,
> -name=>"custom$j",
> -value=>"$in_field[$j]" ) . ', ';
> }
> print $query->header(-cookie=>[$cookie_custom_fields]);
>
You can put several values into a single cookie like so:
my $cookie = $query->cookie(
-domain => $domainname,
-name => 'customfields',
-value => \@custom_fields
);
print $query->header(-cookie => $cookie);
Read the CGI docs again: perldoc CGI
-
Re: How to concatenate cookies
On May 10, 11:35 pm, "Mumia W." <paduille.4061.mumia.w
+nos...@earthlink.net> wrote:
> You can put several values into a single cookie like so:
>
> my $cookie = $query->cookie(
> -domain => $domainname,
> -name => 'customfields',
> -value => \@custom_fields
> );
> print $query->header(-cookie => $cookie);
>
> Read the CGI docs again: perldoc CGI
Thanks, but I am actually looking for each cookie to be seperate, so
have multiple cookies in one variable $cookie. The docs says:
you may concatenate the cookies together with ``; ''
I am not sure what those characters mean ``; " ?
-
Re: How to concatenate cookies
On 11 May, 06:09, dr_phill...@yahoo.com wrote:
> On May 10, 11:35 pm, "Mumia W." <paduille.4061.mumia.w
>
> +nos...@earthlink.net> wrote:
> > You can put several values into a single cookie like so:
>
> > my $cookie = $query->cookie(
> > -domain => $domainname,
> > -name => 'customfields',
> > -value => \@custom_fields
> > );
> > print $query->header(-cookie => $cookie);
>
> > Read the CGI docs again: perldoc CGI
>
> Thanks, but I am actually looking for each cookie to be seperate, so
> have multiple cookies in one variable $cookie. The docs says:
>
> you may concatenate the cookies together with ``; ''
>
> I am not sure what those characters mean ``; " ?
I'd guess they'd mean a literal semicolon (whereas you had a comma).
But one of my top rules of programming is "always use the most natural
representation of things". The most natural type of variable to
represent a list of things is an array (not a delimited string).
my @cookie_custom_fields;
for my $j ( 0 .. $#custom_fields ) {
push @cookie_custom_fields => $query->cookie(-domain=>
$domainname,
-name=>"custom$j",
-value=>"$in_field[$j]" );
}
print $query->header(-cookie=>\@cookie_custom_fields);
-
Re: How to concatenate cookies
On 05/11/2007 12:09 AM, dr_phill123@yahoo.com wrote:
> On May 10, 11:35 pm, "Mumia W." <paduille.4061.mumia.w
> +nos...@earthlink.net> wrote:
>> You can put several values into a single cookie like so:
>>
>> my $cookie = $query->cookie(
>> -domain => $domainname,
>> -name => 'customfields',
>> -value => \@custom_fields
>> );
>> print $query->header(-cookie => $cookie);
>>
>> Read the CGI docs again: perldoc CGI
>
> Thanks, but I am actually looking for each cookie to be seperate, so
> have multiple cookies in one variable $cookie. The docs says:
>
> you may concatenate the cookies together with ``; ''
>
> I am not sure what those characters mean ``; " ?
>
What docs are you talking about? I can't find that exact language in
either CGI.pm's POD, or in RFC2109. In RFC2109, something close to the
syntax you talk about is described, but I can't find anything that
suggests that CGI.pm supports that.
The description of raw_cookie() is a little confusing. While you can get
cookies which have been concatenated with "; " (semicolon and space)
from CGI::raw_cookie(), there does not seem to be a way to create such
cookies.
Anyway, RFC2109 says that cookies are separated by commas:
> Informally, the Set-Cookie response header comprises the token Set-
> Cookie:, followed by a comma-separated list of one or more cookies.
-
Re: How to concatenate cookies
Brian McCauley wrote:
> print $query->header(-cookie=>\@cookie_custom_fields);
Thanks, this worked perfectly.
-
Re: How to concatenate cookies
Mumia W. wrote:
> > I am not sure what those characters mean ``; " ?
> >
>
> What docs are you talking about? I can't find that exact language in
> either CGI.pm's POD, or in RFC2109. In RFC2109, something close to the
Sorry, I got it from the CGI::Cookie docs.
Similar Threads
-
By Application Development in forum labview
Replies: 1
Last Post: 08-02-2007, 01:40 PM
-
By Application Development in forum Inetserver
Replies: 1
Last Post: 07-06-2007, 02:54 AM
-
By Application Development in forum Inetserver
Replies: 0
Last Post: 07-05-2007, 07:27 PM
-
By Application Development in forum Adobe Tools
Replies: 2
Last Post: 09-09-2006, 03:24 PM
-
By Application Development in forum CSharp
Replies: 3
Last Post: 07-10-2006, 03:12 PM