Question : cookie data --  cgi/perl

Hello Experts,

I have a page which is deleting and setting the data in the cookie, for some reason when I call the function it is displaying the cookie information on the page, something like this

"Set-Cookie: UserCook=; path=/ Set-Cookie: ZvisionUser=; path=/ Expires: Thu, 07 Aug 2008 22:35:57 GMT Date: Fri, 08 Aug 2008 22:35:57 GMT Content-Type: text/html; charset=ISO-8859-1 "

This is happening when I call the SetCgiCookie(attached) from this function

sub DeleteProductCookie

{

      my(@Idlist)=@_;

      my @CookiePlist=GetProductCookie();

      

      foreach $str(@CookiePlist)

      {

            my @temp=split(',',$str);

            $ProductHash{$temp[0]}=$temp[1]+$ProductHash{$temp[0]};

      }



      my @ProductId=keys %ProductHash;

      for(my $i=0;$i<=$#Idlist;$i++)

      {

            delete $ProductHash{$Idlist[$i]};      

            

      }

      

      my @ProductId=keys %ProductHash;

      my $setcokkie="";

      for(my $i=0;$i<=$#ProductId;$i++)

      {

            $setcookie=$setcookie.'~'."$ProductId[$i],$ProductHash{$ProductId[$i]}";      

      }

      SetCgiCookie($Usercookiename,$setcookie);         



}

Can someone please let me know if the SetCgiCookie function is not correct?

Your help is much appreciated.

Thanks
Sam
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
sub SetCgiCookie
 
{
 
 
 
my ($cookiename,$cookievalue)=@_;
 
my $cookie = $query->cookie(-name => "$cookiename",-value =>"$cookievalue",-path => "/");
 
	if ($logoutClicked == 1)
 
	{	my $cookie1 = $query->cookie(-name => "$userCookie",-value =>"",-path => "/");
 
     	print $query->header(-expires => "-1d", -cookie => [$cookie,$cookie1]);
 
	}
 
	else
 
	{
 
 		print $query->header(-expires => "-1d", -cookie => $cookie);
 
	}
 
}
Open in New Window Select All

Answer : cookie data --  cgi/perl

1:
2:
3:
4:
5:
6:
7:
8:
sub SetProductCookie {
    my($productid,$quantity,$newdata1,$newdata2)=@_;
    
    my $cookievalue=GetCgiCookie($Usercookiename);
    $cookievalue=$cookievalue."~$productid,$quantity,$newdata1,$newdata2";
    my $cookie = $query->cookie(-name => "$Usercookiename",-value =>"$cookievalue",-path => "/");
    print $query->header(-expires => "-1d", -cookie => $cookie);	
}
Open in New Window Select All
Random Solutions  
 
programming4us programming4us