Solved

Will this cold fusion code work to authenticate a user?

Posted on 2004-08-01
5
208 Views
Last Modified: 2010-04-06
Not sure if the syntax is correct.  Please validate.

<cfif isdefined("FORM.userID")>
      <cfif Form.user_name EQ "hkbpics" and Form.user_password EQ "password1">
    <!--- Get user info, first name, last name and access level. --->
      <cfset SESSION.Auth = StructNew()>
      <cfset SESSION.Auth.IsLoggedIn = "Yes">
      <!--- Everything is ok. Send the user to menu template. --->
      <cflocation url="menu.cfm">
      </cfif>
</cfif>
0
Comment
Question by:gmahler5th
5 Comments
 
LVL 7

Expert Comment

by:vnvk
ID: 11694468
instead od isdefined, use parameterexists
0
 

Author Comment

by:gmahler5th
ID: 11698176
Okay, so what about my second cfif.  Will this work?

<cfif Form.user_name EQ "hkbpics" and Form.user_password EQ "password1">
    <!--- Get user info, first name, last name and access level. --->
      <cfset SESSION.Auth = StructNew()>
      <cfset SESSION.Auth.IsLoggedIn = "Yes">
      <!--- Everything is ok. Send the user to menu template. --->
      <cflocation url="menu.cfm">
     </cfif>
0
 
LVL 21

Assisted Solution

by:pinaldave
pinaldave earned 150 total points
ID: 11700791
Hi gmahler5th,

http://www.edgewebhosting.net/cfdocs/Developing_ColdFusion_Applications/appSecurity10.html
here is answer to your question.


Regards,
---Pinal
0
 
LVL 9

Accepted Solution

by:
Jerry_Pang earned 350 total points
ID: 11713068
Okay, so what about my second cfif.  Will this work?

<cfif Form.user_name EQ "hkbpics" and Form.user_password EQ "password1">
    <!--- Get user info, first name, last name and access level. --->
      <cfset SESSION.Auth = StructNew()>
      <cfset SESSION.Auth.IsLoggedIn = "Yes">
      <!--- Everything is ok. Send the user to menu template. --->
      <cflocation url="menu.cfm">
</cfif>

little modification
<cfif not isdefined("SESSION.Auth ")>
 <cfif Form.user_name EQ "hkbpics" and Form.user_password EQ "password1">
    <!--- Get user info, first name, last name and access level. --->
      <cfset SESSION.Auth = StructNew()>
      <cfset SESSION.Auth.IsLoggedIn = "Yes">
      <!--- Everything is ok. Send the user to menu template. --->
      <cflocation url="menu.cfm">
 </cfif>
</cfif>

Yes, this would work, this is the simplest user authentication i guess.
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11716209
glad to help you.
Have a good day!
---Pinal
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question