Solved

Element CFID is undefined in SESSION

Posted on 2004-08-27
17
8,730 Views
Last Modified: 2013-12-20
I have an application that has been working for the past 5 months now with no problem.  All of the sudden, after I log out and attempt to log back in, I get the following error:

Element CFID is undefined in SESSION.

This is the pertinent code in the application.cfm file:
<!---application tag--->
  <cfapplication name="RMCI"
    SessionManagement="yes"
   SETCLIENTCOOKIES="NO">


 <cfset CookieDomain=".domain.com">
                    
<!---name application, and enable Session and Application variables--->

<CFAPPLICATION  NAME="Security_Test"
   SESSIONMANAGEMENT="YES"
   SESSIONTIMEOUT=#CreateTimespan(0,0,15,0)#
   SETCLIENTCOOKIES="NO">

<CFLOCK SCOPE="SESSION" TYPE="READONLY" TIMEOUT="5">
     <CFCOOKIE NAME="CFID" VALUE="#SESSION.CFID#">
     <CFCOOKIE NAME="CFTOKEN" VALUE="#SESSION.CFTOKEN#">
</CFLOCK>
             
use cf_sessionWatch to warn users when they are about to timeout --->
<cf_sessionWatch launchTime="15">

This is the information from the logout.cfm file - When I commented this out; the error went away, but the session never dies:

<cfset user=session.Username>

<!--- <cfloop collection=#session# item="i">

  <cfset StructDelete(session,i)>

</cfloop>

Any ideas as to how to resolve this issue?
0
Comment
Question by:liltyga
  • 11
  • 5
17 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 11914696
Hi liltyga,
okey. I think you might have tried this but, once someone login they usually get CFID and CFTOKEN
so, due to any reason they got deleted by another page or session while some one is logged in ...when they try to logout this is what happens.
So, close everything and try to login from the beginning and also make sure that no body else is using system and only you (one user) is using this system.
AFter that, if this happens it means that due to some code or some reason the session is getting deleted.

we had same problem once... due to some reason on our dev server all the sessions were deleted by the code of our API division and we Research division was really researching this problem for long time...

Regards,
---Pinal
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11914718
Hi liltyga,
my team mate asking if you are using same browser for login and logout? This may sound not stupid but just making sure.

Regards,
---Pinal
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11914742
Hi liltyga,
 
sorry for spamming, I should have my all the thoughts together in one post...I am not sure if following post is any applicable but I found saved on my archive. If this confuses you just ignore it ... may be it is the reason.
The CFRegistry tag was recently disabled. On CFMX this affects the CFApplication tag *if* client storage is left to it's default or set to "Registry".

At default, the CFApplicaiton tag has a parameter of clientstorage with a default value of Registry. By disabling the CFRegisty tag, this creates a conflit. To resolve the problem, the CFApplicaiton tag MUST include the clientstorage="Cookie" or clientstorage="Datasource_Name" to ensure that CFMX does not try to access the registry.

Here is an example of a good CFApplication tag.

<cfapplication name="Your_App_Name"
clientmanagement="yes"
sessionmanagement="yes"
setclientcookies="yes"
setdomaincookies="yes"
sessiontimeout="#createTimeSpan(0,8,0,0)#"
applicationtimeout="#createTimeSpan(0,8,0,0)#"
Clientstorage="Cookie"
loginstorage="session">

Regards,
---Pinal
0
 

Author Comment

by:liltyga
ID: 11915808
Not a problem Pinal, I appreciate your response.  Yest the same browser is being used for login and logout.  It didn't start happening until yesterday.  The error doesn't show up unti you login, logout, and try to login again or refresh the page.  If I close the browser and open it again, it is fine until I try to login, logout, and login again.  I had found the same "good CFApplication tag" code through Google, and made some mods to the application.cfm file before I posted this query, but the changees were to no avail.  
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11917577
Hi liltyga,
hum... this sounds like that your application does not have much of the problem except with sessions. When you login it works and when you logout it may be creating some problem ... and when you try to login again it is conflicting with old session ( should not be) but when you start new browser it is opening new session for sure and there is no previous data so it works fine...

okey this could be happening when you delete the session it may not be deleting them right or may be it is deleting only partially ( cfid ) or something... I was wondring if this is not working correct...
<!--- <cfloop collection=#session# item="i">

  <cfset StructDelete(session,i)>

</cfloop>

how about if we try to use structclear(session)

let me knwo what is the output in that case...


Regards,
---Pinal
0
 

Author Comment

by:liltyga
ID: 11918386
I tried it, but unfortunately that didn't work either - I got the same CFID is undefined in Session error when I refreshed the page after logging out, or trying to access the page directly again.  It's so strange - I didn't do anything to this app for so many months, and all the sudden it is doing this.
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11918539
hi lityga,
I am sorry to here that... may be this is due to some other reasons...
may be this is not apropriate but can we see that error or having test account for 10 min or something?
Regards,
---Pinal
0
 

Author Comment

by:liltyga
ID: 11918574
It's actually internal, so I can't send a link, but I can provide more code if needed - all I know is that when I comment out the <cfloop collection=#session# item="i">

  <cfset StructDelete(session,i)>

</cfloop>

the error goes away, but the session is not terminated.  Is there a better way to terminate the session?
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 21

Expert Comment

by:pinaldave
ID: 11918589
structclear(session) is also creating problem for you... so ... hum...
okey... if you use

 structclear(session)


instead of this...

<cfloop collection=#session# item="i">

  <cfset StructDelete(session,i)>

</cfloop>

and it is not working ... am I understanding that correct.
If this works once and does not work second time... is just confusing me...
i use structclear to delete them... complitely.....
Regards,
---Pinal
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11918596
Hi liltyga,
I will go home after 45 min. So I was thinking to solve this issue before that if possible.

Regards,
---Pinal
0
 

Author Comment

by:liltyga
ID: 11918602
Thanks, I tried that and still get this error when logging in:

Element CFID is undefined in SESSION.  
 
 
The error occurred in (directory path): line 24
 
22 :
23 : <CFLOCK SCOPE="SESSION" TYPE="READONLY" TIMEOUT="5">
24 :      <CFCOOKIE NAME="CFID" VALUE="#SESSION.CFID#">
25 :      <CFCOOKIE NAME="CFTOKEN" VALUE="#SESSION.CFTOKEN#">
26 : </CFLOCK>

 
0
 
LVL 21

Assisted Solution

by:pinaldave
pinaldave earned 250 total points
ID: 11918620
Hi liltyga,
I just do not know... about this... i never programmed like this... this is what I usually do in my application.cfm for session...may be you can modify yours...
i never use cookies and session together...I think, session itself is fine... we do not need to set them in cookies... may be you do not need to that...
following is the code from my office session management code of application.cfm

<cfapplication name="dealers_ebizautos_com"
                             sessionmanagement="Yes"    
                             applicationtimeout="#createtimespan(1,0,0,0)#"
                             sessiontimeout="#createtimespan(0,1,0,0)#">


<cfset session.cfid = cfid>
        <cfset session.cftoken = cftoken>
        <cfset session.urltoken = "cfid=#session.cfid#&cftoken=#session.cftoken#">

Regards,
---Pinal
0
 
LVL 21

Assisted Solution

by:pinaldave
pinaldave earned 250 total points
ID: 11918625
Hi liltyga,
this is how i set up cookies....if required.

<cfset cookie.username = get_acct.username>
                <cfset cookie.account_id = get_acct.account_id>
                <cfset session.get_acct = get_acct>

Regards,
---Pinal
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11918660
let me know if any of this is usuful to you.
Regards,
---Pinal
0
 
LVL 17

Accepted Solution

by:
anandkp earned 250 total points
ID: 11928931
0
 

Author Comment

by:liltyga
ID: 11932831
Thanks for all your help!
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 11932849
glad to help you and Anadkp that link is good one.
Regards,
---Pinal
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to count occurrences of each item in an array.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now