On Mon, 12 Nov 2001, Joe Van Meer wrote:

> Thx Christopher for replying. Ok, let me see if I understand you
> correctly...
> The user enters username and password on index.php, this is posted to
> login.php. On login.php after I verify the user is who he/she says they are
> I set a cookie called "accessedbefore" to "yes" and redirect them to the


> main page. Am I allowed to set a cookie and redirect them after determining
> who the user is? How would I redirect them after setting the cookie? Header

You can set a cookie any time before any standard output is sent to the
browser (and before you send a new Location header).

Your login.php can look something like this (with pseudo-ish code) ...

        $input_ok = validate_user_input( $username, $password );
        if( $input_ok ){
                $user_ok = authenticate_user( $username, $password );
                if( $user_ok ){
                        setcookie( "myuser", "ok", time()+7200, "/" );
                        header( "Location: congratulations.html" );
                } else {
                        header( "Location: go_away.html" );
        } else {
                header( "Location: go_away.html" );

        ~Chris                           /"\
                                         \ /     September 11, 2001
                                          X      We Are All New Yorkers
                                         / \     rm -rf /bin/laden

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to