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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

session.User_ID not declared properly 1

Status
Not open for further replies.

wouter

Technical User
Jul 3, 2000
45
NL
I'm using this code when there's a new user. But i get an error which says session.UserID isn't declared properly. He doesn't know what to do with it.

<cfif NOT ISDEFINED (&quot;session.user_id&quot;)>

<cfapplication applicationtimeout=&quot;#CreateTimeSpan(&quot;0&quot;,&quot;1&quot;,&quot;0&quot;,&quot;0&quot;)#&quot; sessionmanagement=&quot;yes&quot; sessiontimeout=&quot;#CreateTimeSpan(&quot;0&quot;,&quot;0&quot;,&quot;30&quot;,&quot;0&quot;)#&quot; name=&quot;UserID&quot;>

<cfset session.UserID = #form.id#>

<cfquery name=&quot;controleeruser&quot; datasource=&quot;pvdata&quot; dbtype=&quot;ODBC&quot;>
Select Count (Medewerker_id) AS aantal
From Medewerkers
Where Medewerker_id = #session.user_id#
AND Medewerkeremail = #form.email#
</cfquery>

<cfoutput>
<cfset ok = #aantal#>
</cfoutput>

<cfif ok EQ 1>
<cfset authorisatie = 1>
<cfelse>
<cfset authorisatie = 0>
</cfif>

Wouter
zure_zult@hotmail.com
To me, boxing is like a ballet, except there's no music, no choreography, and the dancers hit each other.
 
Hi Wouter.


Maybe this is too obvious but I notice that you are checking for the existance of the variable session.user_id in:
<cfif NOT ISDEFINED (&quot;session.user_id&quot;)>

but later set the variable session.UserID
<cfset session.UserID = #form.id#>

but then use session.user_id in your query
Where Medewerker_id = #session.user_id#

I hope I didn't miss the point!
Regards,
Jackie

 
Yes, you're right, but that doesn't cause the error. My code is different know anyway. The problem i had was solved. The code i know use is:

<cfif NOT ISDEFINED (&quot;session.user_id&quot;)>

<cfapplication applicationtimeout=&quot;#CreateTimeSpan(&quot;0&quot;,&quot;1&quot;,&quot;0&quot;,&quot;0&quot;)#&quot; sessionmanagement=&quot;yes&quot; sessiontimeout=&quot;#CreateTimeSpan(&quot;0&quot;,&quot;0&quot;,&quot;30&quot;,&quot;0&quot;)#&quot; name=&quot;UserID&quot;>

<cfparam name=&quot;session.user_id&quot; type=&quot;numeric&quot; default=&quot;0&quot;>

<cfquery name=&quot;controleeruser&quot; datasource=&quot;pvdata&quot; dbtype=&quot;ODBC&quot;>
Select Count (Medewerker_id) AS aantal
From Medewerkers
Where Medewerker_id = #form.id#
AND Medewerkeremail = '#form.email#'
</cfquery>

<cfset session.user_id = #form.id#>

<cfoutput query=&quot;controleeruser&quot;>
<cfset ok = #aantal#>
</cfoutput>

<cfif ok EQ 1>
<cfset authorisatie = 1>
<cfelse>
<cfset authorisatie = 0>
</cfif>

</cfif>

<cfoutput>
Code = #Authorisatie#<br>
</cfoutput>
<cfoutput>
Form.id: #form.id#<br>
Email: #form.email#<br>
Sessie: #session.user_id#
</cfoutput>

This all works great (it doesn't do much, but hey...). When i use a link to go to the next page, i want session.user_id to be accesible on that page to, without having to pass it on through the url (link). I thought session.user_id would be stored on the server (kinda like how a cookie works) and the value would be known and accesible all the time, until the session ends. This is clearly not the case, it just works as a normal variable and is only known on that page. I don't get it...

Wouter

Wouter
zure_zult@hotmail.com
To me, boxing is like a ballet, except there's no music, no choreography, and the dancers hit each other.
 
Hey Wouter,

Do you have the <cfapplication> tag on the next page? If a script executes without the <cfapplication> tag present, none of the session or client variables will be available. I suspect that if you put this in your application.cfm file, you will likely find the variables available on your other pages.

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top