in reply to Error in my code while set cookie?

The problem is with the $status you passed in, and it is not defined. If you pass in a valid value, the cookie will be generated.

use CGI; use HTTP::Cookies; use Data::Dumper; my $q = new CGI; my $status=$q->cookie('ckname'); &set_cookie('abc'); sub set_cookie { my($cookieid)=shift; my @cookies; push @cookies, $q->cookie(-name=>"ckname", -value=>$cookieid, -expires=>'', -path=>'/', -domain=>'.bn.whsites.net'); print $q->header(-cookie=>\@cookies); }

Thsi gives:

Set-Cookie: ckname=abc; domain=.bn.whsites.net; path=/ Date: Wed, 05 Oct 2005 02:29:51 GMT Content-Type: text/html; charset=ISO-8859-1

Replies are listed 'Best First'.
Re^2: Error in my code while set cookie?
by Anonymous Monk on Oct 05, 2005 at 03:05 UTC

    I am reading and printing the text from cookie but, i can't what error may be

    #!/usr/bin/perl use CGI; use HTTP::Cookies; use Data::Dumper; my $q = new CGI; my $cookie_jar = HTTP::Cookies->new; my $status=$q->cookie('ckname'); &set_cookie('abc'); $response = '.bn.whsites.net'; my $cjar = HTTP::Cookies->new; $cjar->extract_cookies($response); my $cookie = $cjar; print $cookie; sub set_cookie { my($cookieid)=shift; my @cookies; push @cookies, $q->cookie(-name=>"ckname", -value=>$cookieid, -expires=>'+2h', -path=>'/', -domain=>'.bn.whsites.net'); print $q->header(-cookie=>\@cookies); }
Re^2: Error in my code while set cookie?
by Anonymous Monk on Oct 05, 2005 at 02:35 UTC
    Thanks pg! now it's working. Thank you very much