in reply to Cookie Hell

You noted that you're not using CGI, but does that mean you can't use CGI and friends? Or you just aren't, for the current code? I've used CGI::Cookie successfully for quite some time, and it works well. Obviously for your design, you'll need to encode the password to obfuscate it, if you're passing that back as a token to the server; Digest::MD5 will help there, or one of the other more secure methods.
if ($ENV{'HTTP_COOKIE'} && $ENV{'HTTP_COOKIE'} =~ /vote/) { $cookie_state = 1; my (@rawCookies) = split (/; /,$ENV{'HTTP_COOKIE'}); my (%cookies); foreach(@rawCookies){ ($key, $val) = split (/=/,$_); $cookies{$key} = $val; } foreach $name (keys %cookies) { $cookie_value = $cookies{$name}; } } else { if ($action =~ /results/ && $poll) { $c1 = new CGI::Cookie(-name => 'vote', -value => [$poll], -expires => '+1M' ); print "Set-Cookie:", $c1, "\n"; } } $c2 = new CGI::Cookie(-name => 'plucker', -value => 'true', -expires => '+1h', -path => '/', -secure => '0', ); $plucker = cookie('plucker'); if (!$plucker) { print header(-cookie=>[$c2]); } else { print header() if ($type ne "Plucker"); }

Also, noticed you mention that you can't 'unset' headers. You certainly can, if you put those headers in a scalar, and undef() them later on, as required. Without code and not knowing your design, I can't say whether this is the right longer-term approach, but it will allow you to 'unset' them at will.

Replies are listed 'Best First'.
Re: Re: Cookie Hell
by TexasTess (Beadle) on Jul 07, 2002 at 22:52 UTC
    #1 Thanks for the great example and indepth reply...I'll find it very useful for completing my project!

    #2. I didn't say I "couldn't" use CGI.pm, I said that by the time the admin folks got it functional...I'd already completed an enormous amount of code and I "can't" sometimes use it and sometimes not use it because the form data defaults to $foo->param and is as a result unavailable to the existing 3k lines of code already developed.

    #3. I didn't say I "Couldn't" unset headers..I was asking if there was a way to unset them...that is really the gist of the original post. You've answered that question with the undef() idea and you've also given me another option using the CGI::Cookie module that will not interfere with my form processing and for that I am Greatful beyond words!

    I've solved my issue today while at work, there were a couple of syntax errors along with a need to change my method for writing the headers...and VIOLA, I am a cookie connoisseur!

    I seriously cannot believe how difficult it is to find a good reference book for programming in CGI/PERL/CGI.pm. I've purchased 6 books since starting this project and find myself constantly frustrated at how scattered they are! They either expect you to follow their strict programming styles totally or you can't use their examples, or they skip and jump around..never really DEFINING and ILLUSTRATING any one issue in any depth! THANK GOD (OR IS IT MONKS!?!) for this site!! TexasTess

    "Great Spirits Often Encounter Violent Opposition From Mediocre Minds" --Einstein