There is an ambiguity in your question. When you say "later in the program, i wanted to change the cookie value...", it is not clear whether you mean during the same page load or during a later page load.

If you are trying to change the cookie during the same page load, you can do that by changing what you plan to send in the HTTP header. But once the header has been sent, you cannot backtrack during the processing of that page and change what was sent in the header.

On the other hand, if you want to change the value of the cookie while processing a later page request, the advice given in the other responses is correct. Just write right over the previous cookie with the identical path and cookie name but with a new value.

Note also, when you say, "It is setting the new value, but its pulling back the old one when I display it to the screen" it would help us to help you if you told us:

The devil is in the details and if you are uncertain about what is going wrong, distrust your narrative description of what is happening and show us the code and/or the output.

HTH, david


In reply to Re: Re-Setting a Cookie by dvergin
in thread Re-Setting a Cookie by Anonymous Monk

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.