Question
How to change cfinclude to cflocation?
Hi,
I have a login page Login.cfm for which I have written code in application.cfc's onRequestStart method,
<cffunction name="OnRequestStart">
<cfargument name = "request" required="true"/>
<cfif IsDefined("Form.logout")>
<cflogout>
</cfif>
<cflogin>
<cfif NOT IsDefined("cflogin")>
<cfinclude template="Login.cfm">
<cfabort>
<cfelse>
<cfif cflogin.name IS "" OR cflogin.password IS "">
<cfoutput>
<h2>You must enter text in both the User Name
and Password fields.
</h2>
</cfoutput>
<cfinclude template="Login.cfm">
<cfabort>
<cfelse>
<cfquery name="loginQuery" dataSource="tdweb">
SELECT username,password,roles
FROM LoginInfo
WHERE
username = '#cflogin.name#'
AND password = '#cflogin.password#'
</cfquery>
<cfif loginQuery.roles NEQ "">
<cfloginuser name="#cflogin.name#" Password = "#cflogin.password#"
roles="#loginQuery.roles#">
<cfelse>
<cfoutput>
<H2>Your login information is not valid.<br>
Please Try again</H2>
</cfoutput>
<cfinclude template="Login.cfm">
<cfabort>
</cfif>
</cfif>
</cfif>
</cflogin>
<cfif GetAuthUser() NEQ "">
<cfoutput>
<form action="Login.cfm" method="Post">
<input type="submit" Name="Logout" value="Logout">
</form>
</cfoutput>
</cfif>
</cffunction>
Now instead of cfinclude I tried using cflocation like this <cflocation url="Login.cfm" addToken="no">,
It throws 127.0.0.1 redirected you too many times error page. Please suggest a solution for this. I don't know the difference between cfinclude and cflocation. Both seems to be same.
Also one more help please. After logging in, the user should land in a page called UserList.cfm. That should be first default page that user should see after logging in. Please let me know how to do that as well. And when user clicks logout button it should take to to the login.cfm page again. Please let me know how to do that as well.Thank you.
