mt2k has asked for the wisdom of the Perl Monks concerning the following question:

Internet Explorer sucks s***!!! (sorry)
I have been trying lately to get a browser independant cookie setter/retriever to work.
Everything I have tried so far has worked on Netscape/Lynx, and other browsers, but NOT Internet Explorer.
I have attempted the following solutions:
  • Manually setting/retrieving cookie Set-Cookie and $ENV{'HTTP_COOKIE'}
  • Using CGI.pm and the cookie function
  • Looking at the script used for the perlmonks login cookie (works on all browsers, even IE) - too confusing

    This has been extremely annoying because it seems that Internet Explorer just has to keep going against me.
    I have searched through a lot of microsoft.com, hoping to find something about how to successfully set cookies in IE.

    Many of my fellow monks have tried over and over again to help me, but noone has been able to find a working solution.
    I know this sounds like an advertisement, but if you have either Netscape or Lynx and then Internet Explorer, try the following address:

  • http://TheGamesPage.virtualave.net
    and see what I mean.
    I have been told that the cookies do not even get set in IE and that shows me the problem right there.
    I don't have time right now to post the code I have tried to use manually/with CGI.pm, but I'll probably post it on Monday/Tuesday.
    I hope I don't have to change to .htaccess or posting content to every page on my site, so I hope a solution arrises soon

    Won't be back til Monday. See ya!

  • Replies are listed 'Best First'.
    Re: Internet Explorer Cookies
    by SuperCruncher (Pilgrim) on Jul 01, 2000 at 14:27 UTC
      Here is a script that I wrote a few weeks back to teach myself about cookies. (Please forgive the reference to my site -- the 100 sexiest women -- but I figure that mt2k is pretty desperate to get this sorted out). I just tried the script with IE, and it works brilliantly. You'll have to change the reference to sharedcode, that's just a small package I wrote with a few shared functions in it.

      #!/usr/bin/perl # # the100sexiestwomen.com - cookies.cgi # # Cookie test. # # ---------------------------------------------- # # History: # - Started 8th June 2000. # use sharedcode; ($id = scalar localtime) =~ s/(:| )//sg; if (defined($ENV{'HTTP_COOKIE'})) { print sharedcode::generate_page("Cookie test.", "Cookie value: $ENV{'HTTP_COOKIE'}<p>Hope it worked.\n"); exit; } print "Set-Cookie: 100sexy=$id; expires=Mon, 01-Jan-2001 00:00:00 GMT\ +n"; print "Location: http://www.the100sexiestwomen.com/100/cookies.cgi\n\n +";
      Hope this helps. BTW I have no idea why PM puts in a plus sign there on the last 2 lines!

        I've had some wierd problems with cookies before, but they weren't limited to IE. The problem seemed to be related to not specifying either the path.

    Re: Internet Explorer Cookies
    by nardo (Friar) on Jul 01, 2000 at 05:46 UTC
      When I log in with guest/guest, I can go back to the index.pl and it will keep me logged in as guest. When I close and reopen IE, it forgets who I am, but this is because you send the browser:
      Set-Cookie: u=Guest; domain=TheGamesPage.virtualave.net; path=/
      Set-Cookie: p=guest; domain=TheGamesPage.virtualave.net; path=/
      since there is no expires value, the cookies will die when the browser is closed.
        Here is an example of setting a cookie that expires.
        Set-Cookie: u=Guest; p=quest; domain=TheGamesPage.virtualave.net; path +=/; expires=Mon, 01-Jan-2001 00:00:00 GMT
    (jcwren) Re: Internet Explorer Cookies
    by jcwren (Prior) on Jul 01, 2000 at 05:36 UTC
      OK, I tried it. How do I know it didn't work? I can't log in with account information I registered, nor can I log in with the guest/guest account. Could you be a little more specific about how this doesn't work under IE5?

      --Chris
    Re: Internet Explorer Cookies
    by mt2k (Hermit) on Jul 04, 2000 at 00:01 UTC
      K... I will update this post here later today.
      The problem is not that the cookie expires when you close the browser. That's a good thing.
      Nardo: To logon as another user, you must first logout of your current user.
      Jcwren: That's the problem right there. After you logged on, you got "Incorrect Logon Information"?
      If so, that is what is wrong. Under several versions of Internet Explorer, the cookie never gets set.
      Under Netscape, Lynx, etc. the 2 cookies DO get set but IE does not seem to take the cookies.
      In the code, I have the path set to '/' and domain set to 'TheGamesPage.virtualave.net'

      Monks with any version of IE: please try the address below and tell me if the cookies are set properly:
      The cookie test