<cfauthenticate securityContext = "security_context" username = "user_ID" password = "password" setCookie = "Yes" or "No" throwOnFailure = "Yes" or "No" authType = "Basic" or "X509">
Authenticates a user, setting a security context for the application. For more information, see the descriptions of IsAuthenticated and AuthenticatedContext.
Web application framework tags
cfapplication,
cfassociate,
cferror,
cflock
cfmodule
Code this tag in the Application.cfm file to set a security context for an application.
Call the IsAuthenticated function to determine if the user has been authenticated. If you specify No for setCookie
, you must call cfauthenticate
for every page in the application (perhaps in an Application.cfm
file).
If you specify throwOnFailure = "Yes"
, you can enclose cfauthenticate
in a cftry
/cfcatch
block to handle possible exceptions programmatically.
<!--- This example shows the use of cfauthenticate in an Application.cfm file ---> <cfif NOT IsAuthenticated()> <cftry> <cfauthenticate securityContext = "Allaire" username = #user# password = #pwd#> <cfcatch type = "Security"> <!--- the message to display ---> <H3>Authentication error</H3> <cfoutput> <!--- Display the message. Alternatively, you might place code here to define the user to the security domain. ---> <P>#cfcatch.message# </cfoutput> </cfcatch> </cftry> </cfif> <cfapplication name = "Personnel"> ...