May grace favor the sanctuary-

As a new initiate into the monestary, I feel somewhat timid in posting so soon, expecting knowledge so rapidly after giving little in return yet.. I hope that I may be favored with a reply...

I am writing a CGI mileage calculator for my employer between several fixed locations. Each time thru, the trip is given four variables to remember ($date, $source, $destination, $miles). These are stored in an array (@table), and output in an html table for the user to see. @table is stored in a cookie (trip_history), then recalled when the script is called again as the user re-submits and adds four new $date, $source, $destination, $miles. These four values are placed at the beginning of @table with unshift(). When the html table is regenerated again, the first value in the array $table(0) is the list stored in the cookie! I have the cookie formatted as a comma-delimited list, but the first value reads like "1, HHS, GHS, 6.7, 2, GHS, MHS, 4.2" instead of $table(0) being 1, $table(1)=HHS, $table(2)=GHS, and so on.

How do I put an array into a cookie, then retrieve it still as an array and modify it yet again and store it as a cookie and retrieve it again...?


In reply to Storing an array in a cookie... by Nacho37

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.