Mike Miessen writes: 

> I am still trying to figure out the problem I have with my login
> scripts.
> I wrote this (copied actually) based on a tutorial located at 
>  
> http://tutorial8.easycfm.com/
>  
> The author says these files all go in the same directory.  The file
> names are.
> - Application.cfm
> - login.cfm
> - login_process.cfm
> - members_only.cfm
>  
> When I call Login.cfm the first thing that happens is application.cfm is
> processed and since I do not yet have session.allowin defined and the
> default is false it gives the "You must login" alert and sends me back
> to login.cfm which repeats the same result.  Oh goodie an endless error
> loop.
>  
> In application.cfm I find the following code.
>  
> <cfif session.allowin neq "true">
>       <cfif CGI.SCRIPT_NAME EQ "login.cfm">
>       <cfelseif CGI.SCRIPT_NAME EQ "login_process.cfm">
>       <cfelse>
>       <!--- this user is not logged in, alert user and redirect to the
> login.cfm page --->
>       <script>
>               alert("You must login to access this area!");
>               self.location="login.cfm";
>       </script>
>       </cfif>
> </cfif>
>  
> As someone pointed out yesterday there are two else statements that
> don't seem to have an action associated with them.
>  
>       <cfif CGI.SCRIPT_NAME EQ "login.cfm">
>       <cfelseif CGI.SCRIPT_NAME EQ "login_process.cfm">

Try <cfif listLast(cgi.script_name, "/") IS NOT "login.cfm" AND 
listLast(cgi.script_name, "/") IS NOT "login_process.cfm"> 

The dilemma you're seeing is that Application.cfm runs before each template 
in the directory....that would INCLUDE login.cfm and login_process.cfm 
(which is where you hit an infinite loop, because you never get to actually 
log in...so your session is never set...so you get sent back to login.cfm).  
The condition checks to see if the current template is either login.cfm or 
login_process.cfm and essentially tells Application.cfm to ignore these two 
templates. 

The reason it's not working for you is that the code, as you got it from 
easycfm.com, assumes that you're on the root directory.  they are checking 
that cgi.script_name EQ "login.cfm"...but cgi.script_name for you may be 
something like /mysite/website/secure/login.cfm (which is why you use the 
listLast() function, with the "/" delimiter). 

Hope this clears it up...or at the very least, doesn't make it any more 
murky :) 

charlie
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to