I'd write out the logic in pseudocode (or function names) beforehand, just to make it easier to figure out the logical flow:

display_login_form() unless logged_in(); display_admin_view() if is_admin(); display_normal_view(); sub logged_in { # check for a cookie # check for a 'pass' parameter if there's no cookie # create a cookie if there's a 'pass' parameter but no # cookie already # return true if either one is valid } sub display_login_form { # print a form that asks for the 'pass' parameter # exit; } sub is_admin { # check if the given password matches the admin password } sub display_admin_view { # show the administrative view } sub display_normal_view { # show the normal view }

I switched to curly braces on the new line after working with Ovid. They take up a bit more space on the screen, but that's a good impetus to keep my subroutines short.


In reply to Re: Re: Re: Re: Re: Re: Re: Cookie not getting stores by chromatic
in thread Cookie not getting stores 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.