> -----Original Message-----
> From: Chris Luksha [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 31, 2002 3:39 PM
> To: CF-Talk
>
> Subject: The darndest time w/ Cookies. Actually form checking.
> I am having the hardest time setting a cookie.  I think it is actually in
> testing for the form field.
>
> Simple login application.
> -User comes to page
> -gets authorized
> -If "remember me" is checked, set a cookie
>
> Here is the code for setting the cookie.
>
> <CFIF get_user.recordcount>
>  <CFSET Session.current_user_id = get_user.userID>
>
>  <!--- If "Remember Me" was checked, set a cookie on user's
> computer w/ User
> ID.  --->
>  <CFIF IsDefined("form.rememberme") IS "Yes">
>  <SCRIPT TYPE="text/javascript"> alert("Hey set a cookie will you!")
> </SCRIPT>   ----For testing of course
>  <CFCOOKIE name="sID" value="#get_user.userID#" EXPIRES="NEVER">
>  </CFIF>
>
> The form field looks like this....
> <INPUT TYPE="checkbox" NAME="rememberme" VALUE="Yes"><FONT
> face="Tahoma">&nbsp;Remember Me</FONT>

The problem here looks to be this line:

<CFIF IsDefined("form.rememberme") IS "Yes">

You can fix this a few different ways:

<cfif IsDefined("FORM.rememberme") AND FORM.rememberme IS "Yes">
...
</cfif>

(this is called short-circuit evaluation; the second condition in the cfif
will only be checked if the form variable is defined)

OR (my personal perference)

<cfparam name="FORM.rememberme" default="No">

<cfif FORM.rememberme IS "Yes">
....
</cfif>



Andy
______________________________________________________________________
Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to