Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Yet another question about cookies.

by enhering (Sexton)
on Jun 07, 2006 at 01:24 UTC ( #553940=perlquestion: print w/replies, xml ) Need Help??
enhering has asked for the wisdom of the Perl Monks concerning the following question:

I've been searching around and found no answer to the following question: When dealing with Microsoft browsers, if I understood correctly, HTTP::Cookies::Microsoft is the only module that permit the access to the file where MSIE saves it's cookies. Am I right or CGI::Cookies deals well with MSIE? A second question is where can I find an example script with comments that shows how to retrieve and set cookies on MSIE browsers using HTTP::Cookies::Microsoft. Thanks for your attention! Eduardo.

Replies are listed 'Best First'.
Re: Yet another question about cookies.
by markjugg (Curate) on Jun 07, 2006 at 01:48 UTC
    CGI::Cookie is what you need, although it's normal to use it through the CGI interface. Cookies are a standard specification. When you read and write cookies, you are using the cookie standard to communicate with the browser.

    How the browser stores the cookie is none of your business.

    HTTP::Cookies::Microsoft seems to be built to solve a different problem. As I understand, it would be useful if you were writing a Windows web browser in Perl that wanted to read the cookies that were already stored by IE. I don't know why someone would want to that...

    However, you seem to be writing a website, so I think CGI::Cookie is the way to go!

Re: Yet another question about cookies.
by sgifford (Prior) on Jun 07, 2006 at 01:49 UTC
    I haven't used HTTP::Cookies::Microsoft, but it looks like it's designed to run on a client machine and poke around inside the Web browser's cookie files. If you're application is running on a Web server and wants to set cookies in clients that connect to it, the standard cookie modules (like CGI::Cookie) will work fine with any modern client, including MSIE.

    I can understand your confusion, since CGI::Cookie talks a lot about "Netscape Cookies". It just calls them that becuase Netscape invented cookies; nowadays they're not Netscape-specific; in fact, they're Documented Standards.

      And what about this node:
      I'm really confused about this. I tried using the code below to set a cookie on a visitor's browser:
      #- Set Cookie -------------------------------------------------------- +---------# sub setCookie { # end a set-cookie header with the word secure and the cookie will o +nly # be sent through secure connections my ($name, $value, $expiration, $path, $domain, $secure) = @_; print "Set-Cookie: "; print ($name, "=", $value, "; expires=", $expiration, "; path=", $path, "; domain=", $domain, "; ", $secure, "\n"); }
      And it works fine on Firefox. On MSIE, cookies are saved on another file, named (my domain name). When the user calls my website from a MSIE, nothing is retrieved. On the other side, when I test it using firefox, cookies are retrieved.Maybe CGI::Cookie handles this. I haven't tried it.

        In Re: Why cookies do not work on some users' windows PC?, the OP had some kind of compatability issue trying to manually create a cookie header, which he may or may not have eventually resolved.

        My guess is that there's some bug in your cookie code, and Mozilla is willing to ignore it while MSIE isn't. You can read through the HTTP cookie specifications carefully, look for some example code, compare your code to working code, etc. Or you can use a module like CGI::Cookie, where the author has already done all of this work for you.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://553940]
Approved by markjugg
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2018-01-22 00:39 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (230 votes). Check out past polls.