Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with session.userid

Status
Not open for further replies.

WannaLearn

Programmer
Jul 10, 2001
210
0
0
US
I'm having some trouble creating a session.userid. No matter what I do, its not working.
This is what I have:

Application.cfm
<cfapplication name="abc123" ClientManagement="No" SessionManagement="Yes" SessionTimeout="#CreateTimeSpan(0,0,30,0)#" SetClientCookies="Yes">

<cfset ds = "abc">
<cfset frmname = "xxx">

<cfinclude template="../../../../123.cfm">

<!--- Check to see if the session variable exists, if not set it. --->
<CFPARAM name="Session.UserID" default="">
<CFIF IsDefined("Session.UserID") EQUAL "No">
<cfset User_ID = Session.UserID>
</CFIF>



page1.cfm
<html>
<body>
<form name"<cfoutput>#frmname#</cfoutput>" action="page2.cfm" method="post">
<table width="330" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="321"><br>Enter your zipcode: <br>
<table width="290" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" width="50%">
<input type="text" name="f6" size="7" maxlength="5" value="">
<input type="hidden" name="ffid" value="1">
<input type="submit" name="SubmitButton" value="Next Page">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>



page2.cfm
<cfset ffid = "#form.ffid#">

<!--- Check to see if the session variable exists, if not redirect them to the login page --->
<CFIF IsDefined("Session.UserID") EQUAL "No">
<cfset User_ID = Session.UserID>
<cfelse>
<cfset User_ID = 99999>
</CFIF>

<form name="<cfoutput>#frmname#</cfoutput>" action="page3.cfm" method="post">
<table cellpadding=0 width="385" align=center
border=0 cellspacing="0" id="form">
<tbody>
<tr valign="MIDDLE">
<td align=right height="28">First name:&nbsp;&nbsp;</td>
<td height="28"> <input name="f1" id="f1" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">Last name:&nbsp;&nbsp;</td>
<td width="59%" height="28"> <input name="f2" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">Email:&nbsp;&nbsp;</td>
<td width="59%" height="28"> <input size=30 name="f3" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">Address:&nbsp;&nbsp;</td>
<td width="59%" height="28"> <input size=30 name="f4" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">City:&nbsp;&nbsp;</td>
<td width="59%" height="28"> <input name="f5" value="">
</td>
</tr>
<tr valign="MIDDLE">
<td align=right width="41%" height="28">Zip Code:&nbsp;&nbsp;</td>
<td width="59%" height="28"> <input maxlength=5 size=10
name="f6" value="<cfoutput>#f6#</cfoutput>"> </td>
</tr>
<tr valign="TOP" align="CENTER">
<td colspan="2" height=""><br> <input type=checkbox value=1 name="f7" checked>
I agre</td>
</tr>
<tr valign="MIDDLE" align="CENTER">
<td colspan="2" height="40">
<input type="hidden" name="ffid" value="1">
<input type=Submit value="Next!" name="SubmitButton">
</td>
</tr>
</tbody>
</table>
</form>



page3.cfm
<cfif isdefined("FORM.ffid")>
<cfif isdefined("FORM.fieldnames")>
<!--- Create empty list of processed variables --->
<cfset fp = "">
<!--- Loop through fieldnames --->
<cfloop index="f_el" list="#FORM.fieldnames#">
<!--- Fix for Orbit Text area( loops through all variables regardless --->
<cfif f_el is not "f999999999">
<!--- Try to find current element in list --->
<cfif f_el IS "ffid" OR f_el IS "SubmitButton">
<cfset fp = ListAppend(fp, f_el)>
</cfif>
<cfif ListFind(fp, f_el) IS 0>
<!--- Make fully qualified copy of it (to prevent acessing the wrong field type) --->
<cfset f_el_qualified = f_el>
<!--- Only record field if form is submited --->
<cfif IsDefined("form.SubmitButton") OR IsDefined("form.SubmitImage.x")>
<!--- Set value for variable outside cfquery to avoid single quote issue --->
<cfset FAV=Evaluate(f_el_qualified)>
<cfquery name="rec" datasource="#ds#">
INSERT INTO Table1 (HFA, User_ID, FFID, fid)
VALUES ('#FAV#', #User_ID#, #ffid#,#removechars(f_el,1,3)#)
</cfquery>
</cfif>
<!--- And add it to the processed list --->
<cfset fp = ListAppend(fp, f_el)>
</cfif>
</cfif>
</cfloop>
</cfif>
</cfif>

<html>
<body>
Thanks.
</body>
</html>


Now, I can't figure out what i'm doing wrong. How do you create a user_id, and then pass it along the process until the user entry has been inserted into the database?
I keep getting blank as my user_id. So, how do I create a session.user_id?
Thanks.
 
change
Code:
<CFIF IsDefined("Session.UserID") EQUAL "No">
to
Code:
<CFIF IsDefined("Session.UserID")>

IsDefined returns boolean, and i dont think EQUAL is a valid operator anyways.


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 
if you still wanted to check for "No" you would say
Code:
<cfif isdefined("session.userID") and session.userID eq "No">

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
It seems like the way he's trying to do it.. is rather like an IsNotDefined() function (which does not exist..

If that's the case... try this..

Code:
<CFIF NOT IsDefined("Session.UserID")>

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top