if cookie doesn't exist { print html headers print html form check form for authenticity set cookie from login forn } else { print html headers print rest of script }