For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > September 2005 > cookies as hidden files









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author cookies as hidden files
Denzil Kruse

2005-09-16, 3:55 am

Hi all,

I read through the docs for CGI::Cookie and learned
how to set a cookie. I do it with line:

my $cookie = new CGI::Cookie(-name=>'name',
-value=>"$name",
-expires=>'+6M');

But, I've found out that when IE creates the cookie,
it creates it as a hidden file, so when I come around
and fetch it, it can't find the cookie and hangs.

But, I saw some cookies that weren't hidden. The list
just got bigger once I told windows to how hidden
files.

So, my question is, how can I create the cookie in
such a way that it isn't hidden? I couldn't find it
in the docs I looked through.

thanks,
Denzil



________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Sean Davis

2005-09-16, 7:55 am



On 9/16/05 12:08 AM, "Denzil Kruse" <denzilphp@yahoo.com> wrote:

> Hi all,
>
> I read through the docs for CGI::Cookie and learned
> how to set a cookie. I do it with line:
>
> my $cookie = new CGI::Cookie(-name=>'name',
> -value=>"$name",
> -expires=>'+6M');
>
> But, I've found out that when IE creates the cookie,
> it creates it as a hidden file, so when I come around
> and fetch it, it can't find the cookie and hangs.
>
> But, I saw some cookies that weren't hidden. The list
> just got bigger once I told windows to how hidden
> files.
>
> So, my question is, how can I create the cookie in
> such a way that it isn't hidden? I couldn't find it
> in the docs I looked through.


Cookies are stored on the client side while they are generated and read from
the server side. Whether or not the cookie is in a hidden file makes no
difference as long as the browser knows where the cookie is, which it
presumably does.

Sean

Sara

2005-09-16, 6:55 pm

1. Are we setting up the proper headers?

use CGI;
my $q = new CGI;

print $q->header(-cookie=>$cookie);

2. I am unable to see the

-domain => 'foo.com';

3. On which machine, you are testing? Your Windows (localhost) or a real web
server?. I have always experienced problems locating cookies for my
localhost (Windows XP, Apache). But when I ran the scripts on my *nix Web
Server, those worked fine.

4. When dealing with cookies and calling the scripts within your browser,
don't hit your refresh button while testing the script, always call the
script in a new window for fresh headers.

I have never experienced HIDDEN cookies, new phenomenon for me atleast.

HTH,
Sara.

----- Original Message -----
From: "Denzil Kruse" <denzilphp@yahoo.com>
To: <beginners-cgi@perl.org>
Sent: Friday, September 16, 2005 9:08 AM
Subject: cookies as hidden files


> Hi all,
>
> I read through the docs for CGI::Cookie and learned
> how to set a cookie. I do it with line:
>
> my $cookie = new CGI::Cookie(-name=>'name',
> -value=>"$name",
> -expires=>'+6M');
>
> But, I've found out that when IE creates the cookie,
> it creates it as a hidden file, so when I come around
> and fetch it, it can't find the cookie and hangs.
>
> But, I saw some cookies that weren't hidden. The list
> just got bigger once I told windows to how hidden
> files.
>
> So, my question is, how can I create the cookie in
> such a way that it isn't hidden? I couldn't find it
> in the docs I looked through.
>
> thanks,
> Denzil
>
>
>
> ________________________________________
__________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> --
> To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
> For additional commands, e-mail: beginners-cgi-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>


Denzil Kruse

2005-09-16, 6:55 pm

Well, this is what I witnessed. I'm using a windows
computer at home. It is configured to display hidden
files. I have a red hat linux server off who knows
where that hosts my site.

I set up a perl script to set and fetch cookies, and
it does so correctly on my computer. But, I went over
to a friend's windows computer, and when it tried to
bring up the site, the browser(IE) hung. Part of the
web site is a flash presentation with music, but the
flash was hanging as well, and there was no music.

So I start looking for the cookies on the local
machine. I couldn't find it, so did a search on the
entire machine. Still couldn't find it, which freaked
me out be because I knew it was there.

So, I went into the folder options or whatever it is
called and told the computer to display hidden files.
The moment I did that, the cookies appeared in windows
explorer in the cookies directory, and the music from
the flash presentation started playing.

So I concluded that if windows explorer couldn't see
the cookie, then IE couldn't either. I suppose I
could do a few more experiments, but it sure seems
like that cookie was hidden and couldn't be found.

Before I displayed the hidden files, there were
cookies in the cookies directory. So some cookies
aren't considered hidden files and others are. I'm
trying to figure out how to get my cookies to not be
hidden/system files so they appear.

Denzil

--- Sean Davis <sdavis2@mail.nih.gov> wrote:

> Cookies are stored on the client side while they are
> generated and read from
> the server side. Whether or not the cookie is in a
> hidden file makes no
> difference as long as the browser knows where the
> cookie is, which it
> presumably does.
>
> Sean
>


>





__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
Denzil Kruse

2005-09-16, 6:55 pm



--- Sara <sara.samsara@gmail.com> wrote:

> 1. Are we setting up the proper headers?
>
> use CGI;
> my $q = new CGI;
>
> print $q->header(-cookie=>$cookie);


I think so. I did it this way:

my $cookie = new CGI::Cookie(-name=>'name',
-value=>"$name",
-expires=>'+6M');

print "Set-Cookie: $cookie\n";

> 2. I am unable to see the
>
> -domain => 'foo.com';
>


I left that out. The docs say "If no domain is
specified, then the browser will only return the
cookie to servers on the host the cookie originated
from." Which is what I want I think?

> 3. On which machine, you are testing? Your Windows
> (localhost) or a real web
> server?. I have always experienced problems locating
> cookies for my
> localhost (Windows XP, Apache). But when I ran the
> scripts on my *nix Web
> Server, those worked fine.


yes, I'm using a linux red hat server off on the
internet somewhere.

>
> 4. When dealing with cookies and calling the scripts
> within your browser,
> don't hit your refresh button while testing the
> script, always call the
> script in a new window for fresh headers.


Okay.

> I have never experienced HIDDEN cookies, new
> phenomenon for me atleast.


I'll go through and double check. It could have been
some weird coincidence, but I don't think so.
>
> HTH,
> Sara.


Thanks for your help,
Denzil



__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
Bob Showalter

2005-09-16, 6:55 pm

Denzil Kruse wrote:
> Well, this is what I witnessed. I'm using a windows
> computer at home. It is configured to display hidden
> files. I have a red hat linux server off who knows
> where that hosts my site.
>
> I set up a perl script to set and fetch cookies, and
> it does so correctly on my computer. But, I went over
> to a friend's windows computer, and when it tried to
> bring up the site, the browser(IE) hung. Part of the
> web site is a flash presentation with music, but the
> flash was hanging as well, and there was no music.


Whatever problem this is, it isn't a Perl problem. Your CGI script neither
reads nor writes files on the client PC; the browser handles all that.
Sounds like your friend's browser is broken? Or perhaps he has cookies
disabled, in which case any cookies sent by your script are simply discarded
and you won't see them come back.

Denzil Kruse

2005-09-16, 6:55 pm

I've spent the morning trying to reproduce it on my
machine and my brothers, and can't seem to do it. It
must have been some kind of coincidence or fluke.

Thanks for your help everyone. I'll let you know if I
ever figure it out.

Denzil

--- Bob Showalter <bob_showalter@taylorwhite.com>
wrote:

> Whatever problem this is, it isn't a Perl problem.
> Your CGI script neither
> reads nor writes files on the client PC; the browser
> handles all that.
> Sounds like your friend's browser is broken? Or
> perhaps he has cookies
> disabled, in which case any cookies sent by your
> script are simply discarded
> and you won't see them come back.
>



________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com