Question
Login Server behavior problem
Hello,
I'm trying to have a couple of pages with restricted access on our website.
Using DWMX2004 and Coldfusion on Windows XP.
I used the login server behavior to achieve this.
It seems to work fine when the user name (email address in this case) and password are not in the database, redirecting to the failed login page, but when the user and password are correct I get an error message ("Variable MM_LOGINACTION is undefined") and the redirection doesn't happen.
I'm far from an expert, and I'm struggling to understand the code, especially the reason why a CGI variable is used...
Could anyone please help me ?
Thanks in advance.
Ann
Here is the code of my login page (which is not in the root directory, but in a folder ../en/):
<cfif IsDefined("FORM.txtEmail")>
<cfset MM_redirectLoginSuccess="brochures_download.cfm">
<cfset MM_redirectLoginFailed="brochures_new.cfm">
<cfquery name="MM_rsUser" datasource="Calliope">
SELECT UserEmail,UserPass FROM tblUsers WHERE UserEmail='#FORM.txtEmail#' AND UserPass='#FORM.txtPass#'
</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=FORM.txtEmail>
<cfset Session.MM_UserAuthorization="">
</cflock>
<cfif IsDefined("URL.accessdenied") AND false>
<cfset MM_redirectLoginSuccess=URL.accessdenied>
</cfif>
<cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
<cfcatch type="Lock">
<!--- code for handling timeout of cflock --->
</cfcatch>
</cftry>
<cfelse>
<cflocation url="#MM_redirectLoginFailed#" addtoken="no">
</cfif>
<cfelse>
<cfset MM_LoginAction=CGI.SCRIPT_NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_LoginAction=MM_LoginAction & "?" & XMLFormat(CGI.QUERY_STRING)>
</cfif>
</cfif>
<html>
<head>
...
</head>
<body>
....
<form ACTION="<cfoutput>#MM_loginAction#</cfoutput>" METHOD="POST" name="FORM">
<table width="100%" cellpadding="2" cellspacing="2">
<tr>
<td>Your email </td>
<td><input name="txtEmail" type="text" id="txtEmail" size="65"></td>
</tr>
<tr>
<td>Password</td>
<td><input name="txtPass" type="text" id="txtPass" size="8"></td>
</tr>
<tr>
<td> </td>
<td><input name="Login" type="submit" id="Login" value="Login"></td>
<td> </td>
</tr>
</table>
</form>
...
</body>
</html>
I'm trying to have a couple of pages with restricted access on our website.
Using DWMX2004 and Coldfusion on Windows XP.
I used the login server behavior to achieve this.
It seems to work fine when the user name (email address in this case) and password are not in the database, redirecting to the failed login page, but when the user and password are correct I get an error message ("Variable MM_LOGINACTION is undefined") and the redirection doesn't happen.
I'm far from an expert, and I'm struggling to understand the code, especially the reason why a CGI variable is used...
Could anyone please help me ?
Thanks in advance.
Ann
Here is the code of my login page (which is not in the root directory, but in a folder ../en/):
<cfif IsDefined("FORM.txtEmail")>
<cfset MM_redirectLoginSuccess="brochures_download.cfm">
<cfset MM_redirectLoginFailed="brochures_new.cfm">
<cfquery name="MM_rsUser" datasource="Calliope">
SELECT UserEmail,UserPass FROM tblUsers WHERE UserEmail='#FORM.txtEmail#' AND UserPass='#FORM.txtPass#'
</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=FORM.txtEmail>
<cfset Session.MM_UserAuthorization="">
</cflock>
<cfif IsDefined("URL.accessdenied") AND false>
<cfset MM_redirectLoginSuccess=URL.accessdenied>
</cfif>
<cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
<cfcatch type="Lock">
<!--- code for handling timeout of cflock --->
</cfcatch>
</cftry>
<cfelse>
<cflocation url="#MM_redirectLoginFailed#" addtoken="no">
</cfif>
<cfelse>
<cfset MM_LoginAction=CGI.SCRIPT_NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_LoginAction=MM_LoginAction & "?" & XMLFormat(CGI.QUERY_STRING)>
</cfif>
</cfif>
<html>
<head>
...
</head>
<body>
....
<form ACTION="<cfoutput>#MM_loginAction#</cfoutput>" METHOD="POST" name="FORM">
<table width="100%" cellpadding="2" cellspacing="2">
<tr>
<td>Your email </td>
<td><input name="txtEmail" type="text" id="txtEmail" size="65"></td>
</tr>
<tr>
<td>Password</td>
<td><input name="txtPass" type="text" id="txtPass" size="8"></td>
</tr>
<tr>
<td> </td>
<td><input name="Login" type="submit" id="Login" value="Login"></td>
<td> </td>
</tr>
</table>
</form>
...
</body>
</html>