1

I have a survey form with 5 ques, there is one question on each page and user clicks through them with next button on the page. Now, the user is not logged in, I want to set a session variable only when the user takes the first ques on form and clicks next. But I am getting userid not defined in session for the line 2. I am not really sure what I am doing wrong here. Can anyone suggest if they see what is going on. I don't want to be creating multiple userids every time he hits next button. Thanks

<cfif structKeyExists(FORM, "user_mode") and form.user_mode EQ "next"> <cfif NOT ( StructKeyExists(session,userid) )> <cfquery name="insertuser" datasource="#application.datasource#"> INSERT INTO survey_user(ip_address) VALUES (<cfqueryparam cfsqltype="cf_sql_varchar" value="#CGI.REMOTE_ADDR#" />) </cfquery> </cfif> </cfif> 

1 Answer 1

6
StructKeyExists(session,userid) 

should be:

structKeyExists( session, 'userid' ) 

Note the quotes. Without them it's looking for the variable "userid" rather than the key name "userid".

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.