<erl>

out(A) ->
    L = case (A#arg.req)#http_request.method of
            'GET' ->
                yaws_api:parse_query(A);
            'POST' ->
                yaws_api:parse_post(A)
        end,
    case {lists:keysearch("user", 1, L),
          lists:keysearch("password", 1, L)} of
        {{value, {_, User}}, {value, {_,Passwd}}} ->
            case chat:login(User, Passwd) of
                {ok, Cookie} ->
                    [yaws_api:setcookie("sessionid", Cookie),
                     {redirect_local, {rel_path,"chat.yaws"}}];
                {error, Reason} ->
                    chat:display_login(A, Reason)
            end;
        _ ->
            chat:display_login(A, "badly formated POST/GET")
    end.

</erl>
