Solved

Will this cold fusion code work to authenticate a user?

Posted on 2004-08-01
5
206 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
Comment Utility
instead od isdefined, use parameterexists
0
 

Author Comment

by:gmahler5th
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
glad to help you.
Have a good day!
---Pinal
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now