Cookies

D

dave h

Hi, I'm unable to get cookies working on my IIS 6 Server and IE6 browser.
I'm using the latest version of Active Perl. I have a "home" page that runs
a perl cgi script that creates a cookie and also tries to read it when the
page is called again. I have a second page that calls the home page to
simulate a second request for the home page. I assume that the second time
the page is called the cookie should be present. The problem is that the
cookie never seems to get created. Any ideas on what is wrong with either
my approach or the syntax for creating the cookie?

Here is the "Home" page:

<html> <head>
<meta http-equiv="Content-Type" content="text/html">
<meta name="hideHeader" content="">
<title>index</title>
</head> <body>
this is a cookie test
<hr><!--#exec cgi="/perl1/CookieScript.pl" --> <hr>
<a href="http://localhost/perl1/perlHelper.htm">Another Page</a>
</body></html>

Here is the "Other" page - it just calls the home page - I assume the second
request for the home page should present the cookie back to the server
script:

<HTML> <HEAD>
<title>perlHelper</title>
</HEAD> <body>
some text<br>
<a href="http://localhost/perl1/index.shtml">Home Page</a>
</body></HTML>

And this is the perl script:

#! c:\perl\bin
use CGI qw/:standard/;
use CGI::Cookie;
my $q = new CGI;
my $c = $q->cookie( -name => "foo", -value => "bar", -expires => "+3M");
# create cookie
print $q->header(-type => "text/html", -cookie => $c); # put
cookie into the header to give to the browser
%cookies = raw_fetch CGI::Cookie; # get cookie
back from browser on subsequent request
foreach (keys %cookies)
{ print "$cookies{$_} <br>\n"; } # look at
all the cookies - I just get a default cookie
$fooValue = $q->cookie("foo"); # another
way to get at foo - never returns the "bar" value
print "fooValue: $fooValue \n"; # no
value printed
 
D

dave h

Hi Gunnar,

Thanks for the insight. However, the only perl cgi programming I've ever
done is via SSI. Can you give me a small example of how to call the CGI
script directly from the browser? Thanks - much appreciated.

Dave H.
 
G

Gunnar Hjalmarsson

[ Please type your reply below the quoted part of the message you are
replying to. ]

dave said:
Thanks for the insight. However, the only perl cgi programming
I've ever done is via SSI. Can you give me a small example of how
to call the CGI script directly from the browser?

Just type the URL to the CGI script in your browser's address bar. Or
click this link:

http://localhost/perl1/CookieScript.pl

:)
 
K

krakle

dave h said:
Hi, I'm unable to get cookies working on my IIS 6 Server and IE6 browser.

And the Perl problem is? Cookies are off topic to this newsgroup and
not welcomed here. You shall be warned further by everyone else....
 
G

Gunnar Hjalmarsson

krakle said:
And the Perl problem is? Cookies are off topic to this newsgroup

To many people's surprise, you are almost correct this time. At least,
an in-depth discussion on how to make use of cookies would be off
topic.

However, the OP in this thread has written a Perl program using a
couple of CPAN modules, and since he had reasons to fear that the Perl
code was incorrect, he did have a (perceived) Perl problem. The fact
that the answer leads to a non-Perl cause of the problem is
irrelevant, as long as the OP does not persist in lengthy off topic
discussions or pullutes multiple threads with meaningless comments.
But we have no reasons to believe that he would, have we?
and not welcomed here. You shall be warned further by everyone
else....

B.S.
 
D

dave h

Thanks Gunnar and sorry if I offended anyone with my question. I've worked
with cookies quite a bit with VB-ASP technology and never had this type of
issue so I assumed it was more of a perl coding question. I appreciate the
time you have taken to help me.

Dave H.

Gunnar Hjalmarsson said:
[ Please type your reply below the quoted part of the message you are
replying to. ]

dave said:
Thanks for the insight. However, the only perl cgi programming
I've ever done is via SSI. Can you give me a small example of how
to call the CGI script directly from the browser?

Just type the URL to the CGI script in your browser's address bar. Or
click this link:

http://localhost/perl1/CookieScript.pl

:)
 
G

Gunnar Hjalmarsson

dave said:
Thanks Gunnar and sorry if I offended anyone with my question.

You're welcome, and there is absolutely no reason for you to apologize
for asking the question.
I've worked with cookies quite a bit with VB-ASP technology and
never had this type of issue so I assumed it was more of a perl
coding question.

I was made aware of this SSI restriction only a few weeks ago through
Randal's post.

Hope this is sufficient help so that you can complete whatever you are
doing. If not, i.e. if you would want to further discuss the design of
your web app, comp.infosystems.www.authoring.cgi may be a more
suitable newsgroup.
 
T

Tad McClellan

dave h said:
Thanks Gunnar and sorry if I offended anyone with my question.


I doubt that you have offended anyone (with your question).

(krakle/Pinocchio does not count, as he is a troll and apparently
not a candidate for Mensa membership either. You can safely
discount whatever it says.
)

I appreciate the
time you have taken to help me.


You can pay Gunnar back by learning to properly format followups.

Have you seen the Posting Guidelines that are posted here frequently?



[ snip TOFU ]
 
U

Uri Guttman

TM> I doubt that you have offended anyone (with your question).

TM> (krakle/Pinocchio does not count, as he is a troll and apparently
TM> not a candidate for Mensa membership either. You can safely
TM> discount whatever it says. )

he could join the mensa chapter headed by bush! they have very low
standards for membership.

uri
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,244
Members
46,839
Latest member
MartinaBur

Latest Threads

Top