Sanjay,
In the directory where your pages are put this .....
Application.cfm
<cfapplication name="Schools_Performance"
sessionmanagement="yes"
sessiontimeout=#createtimespan(0,0,30,0)#>
<cfset application.key = "73">
<cfset application.log = "d:\wwwroot\perform\logs\accesslg.txt">
<cfset local_date = setlocale("english (uk)")>
<cfset application.todays_date = lsdateformat(now(),"dd/mmm/yyyy")>
<cfset application.DSN = "SecureDSN">
Create a directory called "LoggedIn" and put this ...
Application.cfm
<cfapplication name="Schools_Performance"
sessionmanagement="yes"
sessiontimeout=#createtimespan(0,0,30,0)#>
<cfset application.key = "73">
<cfset application.log = "d:\wwwroot\perform\logs\accesslg.txt">
<cfset local_date = setlocale("english (uk)")>
<cfset application.todays_date = lsdateformat(now(),"dd/mmm/yyyy")>
<cfset application.DSN = "SecureDSN">
You probably don't need all that but I usually just cut & Paste it ...
You need TWO application.cfm's on ein the main directory and one in the
directory where your login_action page will be (loggedin in this case)
This is the password page which sits in the loggedin directory
<script language="JavaScript"><!--- Please wait when submit button clicked
--->
<!--
function submitForm()
{
document.form_name.clickme.value = "Please Wait...";
document.form_name.clickme.disabled = "disabled";
return true;
}
//-->
</script>
<script language="javascript"><!--- messages in FORM status bar --->
<!--
function field_focus(theField)
{
<cfset url.nl=0>;
document.getElementById('theStatus').innerHTML =
theField.title;
}
//-->
</script>
<CFQUERY NAME= "password_query" DATASOURCE= "WebUserDSN">
SELECT roles
from user_details
Group by roles
Order by roles
</CFQUERY>
<cfset page=#url.page_id#>
<cfform name="form_name" action="login_action.cfm?page_id=#page#"
method="post" onsubmit="submitForm();">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td height="30"></td></tr>
<tr>
<td valign="top" align="left">
<font face="Arial" size="2"><span style="font-family:
Arial; font-size: 10pt">
<b>User Type</b></span>
</font>
</td>
<td valign="top" align="left">
<cfselect name="select_user"
size="1"
message="Please select a user from the list"
query="password_query"
value="roles"
display="roles"
required="Yes">
</cfselect><p></p>
</td>
</tr>
<tr>
<td valign="top" align="left">
<font face="Arial" size="2"><span style="font-family:
Arial; font-size: 10pt">
<b>User Name</b></span>
</font>
</td>
<td valign="top" align="left">
<input type="text" name="entered_UserName"
onfocus="javascript:field_focus(this);" title="Enter your first name then
last name">
</td>
</tr>
<tr>
<td valign="top" align="left">
<font face="Arial" size="2"><span style="font-family:
Arial; font-size: 10pt">
<b>Password</b></span>
</font>
</td>
<td valign="top" align="left">
<input type="Password" name="entered_password"
onfocus="javascript:field_focus(this);" title="Enter your password">
</td>
</tr>
<tr>
<td valign="top" align="right" colspan="2">
<font face="Arial" size="2"><span style="font-family:
Arial; font-size: 10pt">
<input name="clickme" type=submit value="Log In">
</font>
</td>
</tr>
</cfform>
<tr>
<td valign="top" align="left" colspan="2">
<cfif url.nl eq 1>
<cfoutput>
<font face="Arial" size="2"
color=red>Incorrect login details. Please try again</font>
</cfoutput>
<cfelse>
<span style="font-family: Arial; font-size: 8pt">
<font color="#808080">
<div id="theStatus"></div>
</span>
</cfif>
</td>
<td valign="top" align="left" width="8">
</td>
</tr>
</table>
This is the login_action page which again goes in loggedin
<!---
<cf_objectdump object="#Application#">
<hr>
--->
<html>
<head>
</head>
<body>
<cfset Page=#url.page_id#>
<CFQUERY NAME= "password_query" DATASOURCE= "WebUserDSN">
SELECT * FROM user_details
WHERE user_details.roles ='#trim(form.select_user)#'
AND user_details.password='#trim(form.entered_password)#'
AND user_details.users_name='#trim(form.entered_UserName)#'
</CFQUERY>
<cfoutput>
<cfif password_query.RecordCount is 0>
<cffile action="Append"
file="#application.log#"
output="#DateFormat("#Now()#")#, #TimeFormat("#Now()#")# ACCESS
DENIED! username = #trim(form.select_user)# Password
= #trim(form.entered_password)#.">
<cflocation url="../loggedin/password.cfm?page_id=#page#&nl=1">
<cfelse>
<cffile action="Append"
file="#application.log#"
output="#DateFormat("#Now()#")#, #TimeFormat("#Now()#")#,
#password_query.users_name# LOGGED IN">
<cflock timeout="10"
type = "exclusive"
scope = "session">
<cfset session.loggedin="1">
<cfset session.user
= "#password_query.users_name#">
<cfset session.access_rights
= "#password_query.roles#">
</cflock>
<cfif password_query.roles eq 'Head Teacher'>
<cflocation url="../#page##password_query.access#">
</cfif>
<cflocation url="../#Page#">
</cfif>
</cfoutput>
</body>
</html>
Your default page or any that requires login has this ...(pages sit in the
default directory)
<!--- Is user logged in ? --->
<cfif not isdefined("session.loggedin")>
<cflocation url="loggedin/password.cfm">
</cfif>
Hope this helps. Its my simple login system that seems to work. Its not
fantastically secure but you could use the key and <cfencode> to encode the
password if you like. I think this makes it a little more secure ...I only
have to keep this away from naughty internals ......
Regards - Paul
*************************************************************************************************
The information contained within this e-mail (and any attachment) sent by Birmingham
City Council is confidential and may be legally privileged. It is intended only for
the named recipient or entity to whom it is addressed. If you are not the intended
recipient please accept our apologies and notify the sender immediately, or telephone
+(44) 121 303 6666. Unauthorised access, use, disclosure, storage or copying is not
permitted and may be unlawful. Any e-mail including its content may be monitored and
used by Birmingham City Council for reasons of security and for monitoring internal
compliance with the office policy on staff use. E-mail blocking software may also be
used. Any views or opinions presented are solely those of the originator and do not
necessarily represent those of Birmingham City Council. We cannot guarantee that this
message or any attachment is virus free or has not been intercepted and amended.
*************************************************************************************************
--
These lists are syncronised with the CFDeveloper forum at
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by
activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*
To unsubscribe, e-mail: [EMAIL PROTECTED]