develooper Front page | perl.beginners | Postings from December 2002

get COOKIES with 'HTTP_COOKIE' ??

Thread Next
From:
Erik Browaldh
Date:
December 16, 2002 04:21
Subject:
get COOKIES with 'HTTP_COOKIE' ??
Message ID:
3DFDC3E0.5050508@pool.informatik.rwth-aachen.de
Hello!

what am I doing wrong with these co-operating perl-scripts?
the first script sets a cookie, but I cant retrieve them when running 
the 2nd..
Something wrong with the $cookies=$ENV{'HTTP_COOKIE'};
?

thanks in advanced!
Erik



the first script with cookies:
--------------------------------------

#!/usr/bin/perl -w
alarm(30);#processen dödar sig själv efter 30 sek
$POST_MAX=5000;# max 5000 bytes für uploadas
use CGI::Carp qw(fatalsToBrowser);# fel-rapporter -> Browsern
use CGI qw(:standard);

$cookie1=cookie(-name=>'erik',
        -value=>'test_cookie',
        -expire=>'+3h');

print header(-cookie=>[$cookie1]);

# END script 1

the second script with cookies:
-----------------------------------------

#!/usr/bin/perl -w
alarm(30);#processen dödar sig själv efter 30 sek
$POST_MAX=5000;# max 5000 bytes für uploadas
use CGI::Carp qw(fatalsToBrowser);# fel-rapporter -> Browsern
use CGI qw(:standard);

print "Content-type: text/plain\n\n";

$cookies=$ENV{'HTTP_COOKIE'};
if ($cookies=~/name=/){
  $cookie1=$cookies;
  $cookie1=~s/name=//;
  $cookie1=~s/:.*//;
  print "Cookie 1: $cookie1\n";
}
else {
  print "it doesnt exist any cookie!";
}

# END script 2




Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About