I would guess by your last response, that you are not really getting this. So let me have a stab at the risk of being lambasted by those who know far more than I do.

Firstly, are you familiar with..
use CGI;

or are you still using some form of &read_form() subroutine to get your <form> data? If so, stop using it immediately (or sooner.)

Use this instead...
use CGI;
my $query = new CGI;
my $form_data = $query->param('field_name'); ## That's all you need to get form data

... and if you are wondering what the 'my' is, then you are NOT using 'strict'. Strict will more closely contol the 'scope' of your variables and will prevent stupid spelling mistakes.

ALL your CGI perl scripts should begin with...
use strict;
use CGI;
my $query = new CGI;

Most of the responses in this thread assume a knowledge of CGI. I use very little of CGI's capabilities. I mainly use it to get data from my <form> and cookies. So here's an easily understood approach to set and read a simple, session-persistant cookie.

Set a cookie:
my $cookie = "cookie_name=some_value"; # a cookie is simply a name/value pair
print "Content-Type: text/html\n";
print "Set-Cookie: $cookie\n\n";

Read a cookie:
my $cookie = $query->cookie('cookie_name'); # using CGI

Clear a cookie:
my $cookie = "cookie_name='';expires=01 Jan 2000 00:00:00";

This is really basic but should be enough to get you started. Next you will need to read up on cookies in general. There a lot more to learn.


In reply to Re: How do I use HTTP Cookies? by nedals
in thread How do I use HTTP Cookies? by Spidy

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.