Yes thats exactly what it should do. But in the first instance I define the
session.user_name as a unique number. so the next time round it will update the
table. I know why the query isn't working, it shouldn't be getting the na in the
first place.
Thanks everyone..
>>> [EMAIL PROTECTED] 01/02/01 10:07AM >>>
Session variables do time out after a period of time. If it's not defined, I don't
think you
would want to update your table, but rather force the user to log in again.
Based on your code, it looks as if the user hits the homepage and the
variable session.user_name is not defined. It runs through the first set of code,
assigning defaults.
Then the person hits a second page, thus re-running the application.cfm.
Session.user_name is defined as the default, which is NA so it goes into the
else statement and executes that code, giving an error.
Michael Ross wrote:
> Sorry to ask a question about this but I am having problems. I set up my
>application.cfm for sessions. I am able to use them almost all the time. Then out
>of the blue I will get this error message.
> ------------------------------------------------------------------------------------
> Error Diagnostic Information
> ODBC Error Code = S0022 (Column not found)
>
> [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'na'.
>
> SQL = "UPDATE tblsessions SET LOGIN = 'rumm01', LOGGEDIN = 'YES' WHERE IDNUMBER= na"
>
> Data Source = "assets"
> ------------------------------------------------------------------------------------
> I know what the error means I can fix that. Its why I am getting this that is
>puzzling. I know its not setting the session.user_name. But why?? out of the blue.
>
> Here is my application page.
>
>-------------------------------------------------------------------------------------------------------------------
> <CFAPPLICATION NAME="surg"
> SESSIONMANAGEMENT="YES"
> SESSIONTIMEOUT="#CREATETIMESPAN(0,0,30,0)#">
>
> <CFIF NOT ISDEFINED('SESSION.USER_NAME')>
> <CFPARAM NAME="SESSION.USER_NAME" DEFAULT="na">
> <CFPARAM NAME="SESSION.NAME" DEFAULT="na">
> <CFPARAM NAME="SESSION.SECUREDGROUP" DEFAULT="na">
> <CFPARAM NAME="SESSION.SESSIONID" DEFAULT="na">
> <CFPARAM NAME="SESSION.LOGIN" DEFAULT="na">
> <CFPARAM NAME="SESSION.ORGROUP" DEFAULT="na">
>
Just for the record, this is bad use of the CFPARAM tag. You already checked
for the existence of session.user_name, so CFPARAM is doing extra work. Can you
assume that if 'session.user_name' exists, so does session.name, session.securegroup,
etc.. etc.. If you want to make this assumption, change your group of CFPARAMs into
CFSETs, or for even efficiency a CFSCRIPT block.
> <CFSET DIFF = 'NO'>
> <CFLOOP CONDITION="DIFF EQ 'NO'">
> <CFSET IDNUMBER= #RANDRANGE(10000, 10000000)#>
> <CFQUERY NAME="ID" DATASOURCE="assets">
> SELECT IDNUMBER
> FROM tblsessions
> WHERE IDNUMBER = #IDNUMBER#
> </CFQUERY>
> <CFIF #ID.RECORDCOUNT# IS 0>
> <CFSET DIFF = 'Yes'>
> </CFIF>
> </CFLOOP>
> <CFLOCK TIMEOUT="30" NAME="#SESSION.USER_NAME#">
> <CFSET SESSION.USER_NAME="#IDNUMBER#">
> </CFLOCK>
> <CFSET TIMET= TIMEFORMAT(NOW(), 'HH:MM:SS')>
> <CFQUERY DATASOURCE="assets" NAME="INSERT">
> INSERT INTO tblsessions(TIMEIN, IDNUMBER, IPADDRESS)
> VALUES('#VARIABLES.TIMET#', #SESSION.USER_NAME#, '#REMOTE_ADDR#')
> </CFQUERY>
>
> <CFELSE>
> <CFSET TIMEL= TIMEFORMAT(NOW(), 'HH:MM:SS')>
> <CFIF #SESSION.USER_NAME# IS NOT 'NA'>
>
Just to be on the safe side, change the above into:
<CFIF #SESSION.USER_NAME# IS NOT 'na'>
You may want to add a CFOUTPUT somewhere so that you can debug the
value of session.username when you get the error.
I didn't think that CF was case sensitive, but that is the only reason I can think of
that
it would enter this if statement.
> <CFQUERY NAME="UPDATE" DATASOURCE="assets">
> UPDATE tblsessions
> SET LASTTIME ='#VARIABLES.TIMEL#'
> WHERE IDNUMBER= #SESSION.USER_NAME#
> </CFQUERY>
> </CFIF>
> </CFIF>
>
> <CFIF ISDEFINED("Cookie.CFID") AND ISDEFINED("Cookie.CFTOKEN")>
> <CFSET CFID_LOCAL = COOKIE.CFID>
> <CFSET CFTOKEN_LOCAL = COOKIE.CFTOKEN>
> <CFCOOKIE NAME="CFID" VALUE="#cfid_local#">
> <CFCOOKIE NAME="CFTOKEN" VALUE="#cftoken_local#">
> </CFIF>
>
--
Jeff Houser | mailto:[EMAIL PROTECTED]
AIM: Reboog711 | ICQ: 5246969 | Phone: 860-229-2781
--
Instant Cold Fusion 4.5 | ISBN: 0-07-213238-8
Due out 3rd Quarter 2001
--
DotComIt, LLC
database driven web data using ColdFusion, Lotus Notes/Domino
--
Half of the Alternative Folk Acoustic Duo called Far Cry Fly
http://www.farcryfly.com | http://www.mp3.com/FarCryFly
--
Promise me no dead end streets, and I'll guarantee we'll have a road
~~~~~~~~~~~~~ Paid Sponsorship ~~~~~~~~~~~~~
Get Your Own Dedicated Win2K Server! Instant Activation for $99/month w/Free
Setup from SoloServer PIII600 / 128 MB RAM / 20 GB HD / 24/7/365 Tech Support
Visit SoloServer, https://secure.irides.com/clientsetup.cfm.
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists