Skip to main content
Participant
June 18, 2007
Question

Login Server behavior problem

  • June 18, 2007
  • 1 reply
  • 304 views
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>

This topic has been closed for replies.

1 reply

Inspiring
June 19, 2007
You need to ensure that sessions have been enabled in your application.cfm
file.

--
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver

Valleybiz Internet Design
www.valleybiz.net

"kangy" <webforumsuser@macromedia.com> wrote in message
news:f557ar$7g6$1@forums.macromedia.com...
> 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>
>
>
>


kangyAuthor
Participant
June 20, 2007
Thnak you very much for your prompt reply, Paul.

Just another novice question...
The DWMX Help File doesn't mention any application.cfm on the pages explaining how to use the login server behavior.
Is this application.cfm compulsory?

I am also installing a ready-made data management system, which is a PHP application, on our web site .
Is it possible/advisable to have both PHP and Coldfusion applications working on the same website or should I rather develop my login page in PHP as well?
(The DMS will be used as an intranet application, whereas the page with restricted access is to be used by prospective customers.)

Thanks again for your help.
Ann