NetConnection.setCredentials( )

NetConnection.setCredentials( ) MethodFlash 6

authenticates a user with a credentials header
myNetConnectionObject.setCredentials(userid, password)

Arguments

userid

A username to be used by the server for authentication.

password

A password to be used by the server for authentication.

Description

The setCredentials( ) method is used when you have an authentication routine on your server that works in tandem with a credentials header. After calling setCredentials( ), the credentials header is attached to every AMF packet generated by the client and going to the server.

As of this writing, only JRun 4 and ColdFusion MX support the credentials header. Calling setCredentials( ) is the same thing as calling the addHeader( ) method, like this:

my_conn.addHeader("Credentials", false, {userid: userid, password: password});

Example

The following code shows the basic syntax of the setCredentials( ) method:

if (connected == null) {
  connected = true;
  NetServices.setDefaultGatewayUrl("http://127.0.0.1/flashservices/gateway");
  var my_conn = NetServices.createGatewayConnection( );
  my_conn.setCredentials(username_txt.text, password_text.text);
}

In this case, the credentials header is added to the AMF packet and every subsequent AMF packet going to the server.

See Also

NetConnection.addHeader( ); Chapter 4, Chapter 5, Chapter 7



    Part III: Advanced Flash Remoting
     
    ASPTreeView.com
     
    Evaluation has ґЩФѕ»ДОѕЩєНexpired.
    Info...