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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |