CGI::Cookie problem

Discussion in 'Perl Misc' started by dalyea@gmail.com, Apr 12, 2007.

  1. Guest

    I am trying to get cookies working on a new site, but no luck.
    The sites are on the same web server and so have a very similar
    Apache setup. Then only difference worth noting is that the
    working code is a dot.com and my new site where the code isn't
    working is a dot.org. Should that make a difference?

    The thing that I believe is broken is fetching the cookie(s).

    The part that sets the cookie is this:

    my $cookie = setZoneCookie($login, $pswd, $login_type);
    my $url=qq(/cgi-bin/new.cgi);
    print $cgi->header( -cookie => $cookie );
    # print $cgi->start_html(-head => meta( { -http_equiv=>"refresh", -
    content=>"0;URL=$url" } ));
    print qq(
    <html>
    <head>
    <meta http-equiv="refresh" content="0;URL=$url">
    </head>
    </html>
    );

    and the cookie is set by:

    our $COOKIEDOMAIN=$cgi->virtual_host();
    sub setZoneCookie {
    my ($login, $pswd, $area) = @_;
    my ($cookie, $c_name, $dough);

    $dough = "$login,$pswd";
    $cookie = new CGI::Cookie(
    -NAME => $cookie_names{$area},
    -VALUE => $dough,
    -EXPIRES => '+24h',
    -DOMAIN => $COOKIEDOMAIN
    );
    return $cookie;
    }

    I can see in debugging that the cookie looks right, just like any
    other cookie:

    xyz_cookie_staff=david%2Ciiikkk; domain=www.xyz.org; path=/;
    expires=Fri, 13-
    Apr-2007 18:28:57 GMT

    The problem I think is fetching the cookie(s):

    sub getLoginCookie {
    my $area = shift;
    my ($dough, @login);

    %cookies = fetch CGI::Cookie;

    if ($cookies{"xyz_cookie_staff"} ) {
    $dough = $cookies{$cookie_names{$area}}->value;
    }

    # Dump
    foreach my $x (sort keys %cookies) {
    &daprint("dump - $x - $cookies{$x}");
    }

    The dump produces:

    dump - CP - CP=%2A; path=/

    I've tried clearing cookies IE-wide, and I've run and re-run the same
    code on other sites with no problem. Any ideas?

    David
     
    , Apr 12, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben
    Replies:
    3
    Views:
    5,937
    Steven Cheng[MSFT]
    Jun 3, 2004
  2. Shapper

    Cookie and Session Cookie Questions.

    Shapper, Apr 27, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    613
  3. =?Utf-8?B?UGF1bA==?=

    Cookie Question (IP as domain and cookie file location)

    =?Utf-8?B?UGF1bA==?=, Jan 10, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    2,541
    Bruce Barker
    Jan 10, 2006
  4. Bill Kelly

    CGI::Cookie.parse problem?

    Bill Kelly, Jan 25, 2006, in forum: Ruby
    Replies:
    0
    Views:
    160
    Bill Kelly
    Jan 25, 2006
  5. Xeno Campanoli
    Replies:
    2
    Views:
    178
    Xeno Campanoli
    Jul 10, 2008
Loading...

Share This Page