Expanded, that 1st line is showing that you are receiving the user's name as input from an HTML form. So...

my $user = $query->param('username');

You can keep this in a hidden field in the form.

$query

is an arbitrary, but oftused name for the CGI session variable. Read all about it in the CGI docs.

$stillloggedin

...simply represents what redirection you would use if the user is found in the cookie, indicating their cookie has not timed out and that they are still logged in. Otherwise (&loggin), take them to an HTML form where they have to re-log-in.

Update: Check out Ovid's CGI course, as well the CGI Tutorials here in the Monastery. Super Searching will find enough on the topic to choke a horse. Also, bear in mind, what I have presented is a very simple solution. It is not secure (though the username is less important this way than the password—another huge topic among monks). There are more complicated scenarios using a database, in combination with cookies, to track who's logged in, etc. Cookies are not always enabled, so database methods might be invoked, and beyond the scope of this thread. (Update 2: fixed typos in my first Update—where's Preview when you need it :^)


—Brad
"Don't ever take a fence down until you know the reason it was put up." G. K. Chesterton

In reply to Re^3: How do I use HTTP Cookies? by bradcathey
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.