}
// login/logout when required or renew cookies
if ($action == 'login') {
    // Form Authentication
    $login = postVar('login');
    $pw = postVar('password');
    $shared = intPostVar('shared');
    // shared computer or not
    $pw = substr($pw, 0, 40);
    // avoid md5 collision by using a long key
    if ($member->login($login, $pw)) {
        $member->newCookieKey();
        $member->setCookies($shared);
        if ($CONF['secureCookieKey'] !== 'none') {
            // secure cookie key
            $member->setCookieKey(md5($member->getCookieKey() . $CONF['secureCookieKeyIP']));
            $member->write();
        }
        // allows direct access to parts of the admin area after logging in
        if ($nextaction) {
            $action = $nextaction;
        }
        $manager->notify('LoginSuccess', array('member' => &$member, 'username' => $login));
        $errormessage = '';
        ACTIONLOG::add(INFO, "Login successful for {$login} (sharedpc={$shared})");
    } else {
        // errormessage for [%errordiv%]
        $trimlogin = trim($login);
        if (empty($trimlogin)) {
            $errormessage = "Please enter a username.";
        } else {