Avatar of Panos
PanosFlag for Germany asked on

Element USER_ID is undefined in SESSION.

Hello experts.
When i logout i have this error:
Element USER_ID is undefined in SESSION.
Any help?
The page is like this
<cfparam name="SESSION.User_id" default="-1">
<cfif "" EQ "" >
  <!--- WA_ClearSession --->
	<cfset clearAll = True >
	<cfset clearThese = ListToArray("", ",") >
	<cfif clearAll>
		 <cflock scope="Session" type="Exclusive" timeout="60" >
			  <cfset StructClear(Session)>
		 </cflock>
	<cfelse>
		<cfloop from="1" to="#ArrayLen(clearThese)#" index="i" >
			<cfset StructDelete(Session, clearThese[i]) >
		</cfloop>
	</cfif>
</cfif>
<cfquery name="q_MyItem" datasource="#dsn#">
SELECT Test_ID, User_ID
FROM dbo.artikel
WHERE User_ID = <cfqueryparam value="#SESSION.User_ID#" cfsqltype="cf_sql_numeric"> 
   AND Test_ID = 1
</cfquery>
 
<cfoutput>#q_MyItem.Recordcount#</cfoutput>

Open in new window

Web ServersWeb Development SoftwareColdFusion Language

Avatar of undefined
Last Comment
Panos

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
dwkd

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Plucka

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
dwkd

more variables = more stuff to keep track of = more hassle
therefore running the query before clearing the session is a bit better .... unless the query involves a variable declared after deleting the session .. which is not the case here
sorry Plucka, i`m not saying your answer is not correct .. just stating a fact :))

good luck  and i hope it helps
Plucka

I agree in principle. It looks like you can move the query at the top. But not sure if thats all the code etc, so I tend not to restructure peoples code rather just offer a simple solution.

If the query needs to be done below the <CFIF or you don't wish to restructure the code then my method is fine, request variables die after the request anyway.

But you should 100% give the points to DWKD as he offered the solution first, I was just adding more detail.
dwkd

lol Plucka ... points are points .. not money :)) .. no1 cares about points heheh .. well at least not me

in my opinion both solutions are correct therefore splitting the points is fair
but it's up to panosms

cheers all  
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER
Panos

Thank you both for your help.
As no one has a problem with the points ,spliting them is the best way for me.
regards Panos.