My web site uses one cookie. However when I inspect the value of $ENV{'HTTP_COOKIE'} using the perl code, I sometimes get more than one instance of the cookie (with the same EXACT name), which may or may not have the same value. For example the value of $ENV{'HTTP_COOKIE'} might be something like: foo=bar1; foo=bar2

I have tried wriing the cookie from the server side perl code and I have tried writing the cookie by javascrypt on the client's PC. Either way can yield the duplicate cookie problem. Even code written in javascrypt with "; path=/" at the end still can eventually yeild 2 cookies.

When I get the duplicate cookie the correct one (i.e. the most current write) is sometimes the 1st one, and sometimes the 2nd. So far I have never seen more than 2 with the same name. The problem can sometimes take several days before it shows itself. The site is currently keeping a record of all visitor's cookies for the site. When I look at this file I can see that 7 out of about 250 of the memebers that log in have this problem and the number having this problem increases now and then.

Does anyone know the mechanism that is causing duplicate cookies, and what to do to stop it? Thank you in advance for anyone that can offer a real solution.


In reply to annoying duplicate cookies by JK_Bean

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.