NetConnection.setCredentials( )


NetConnection.setCredentials( ) Method Flash 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



Flash Remoting
Flash Remoting: The Definitive Guide
ISBN: 059600401X
EAN: 2147483647
Year: 2003
Pages: 239
Authors: Tom Muck

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net