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

Need help on a session error

Status
Not open for further replies.

TOMKA

IS-IT--Management
May 21, 2003
12
NO
Hi I have the following problem:

I have set my appliction.cfm file to handle session management and copied it to the directory under which I have my web pages. I have 4 formX.cfm files and the first one has a cflock command issued for a cfset Session.Name=#Form.name# hence I am setting the session variable to the name inputted on my first form page. Since I want to use the same name without people entering their names for the next 4 pages they go through, I set it up this way. Now the problem is that on a couple of machines from which I go to the page I have my site on, I have no problems updating the data and tracking the forms. However, on some others, I get

--------------------------------------------------------------------------------

Error Occurred While Processing Request
Error Diagnostic Information

An error occurred while evaluating the expression:


#Session.Name#



Error near line 23, column 12.
--------------------------------------------------------------------------------

Error resolving parameter SESSION.NAME


The session variable NAME does not exist. The cause of this error is very likely one of the following things:


The name of the session variable has been misspelled.
The session variable has not yet been created.
The session variable has timed out.


My question is: Why would I get the session variable set right on one computer but not on the others? How can I let multiple sessions run simultaneously independent ofthe computer used to access the pages?
 
Since this behavior is not consistent, I would check the following:

Are the machines that are not working behind a firewall/proxy that is throwing out your cookies (if you are in fact using cookies)?

Do the browsers on the machines that are not working have cookies disabled?


-Tek
 
Well, I have set the cookies option to no in application.cfm. Would this be sufficient?

Here is my application.cfm and form1.cfm which has the lock command.

<!---application tag--->
<cfapplication name=&quot;mysession&quot;
SessionManagement=&quot;yes&quot;
SessionTimeOut=&quot;#CreateTimespan(0,0,2,0)#&quot;
SetClientCookies=&quot;no&quot;>


form1.cfm:

<cflock timeout=&quot;10&quot; throwontimeout=&quot;No&quot; type=&quot;EXCLUSIVE&quot; scope=&quot;SESSION&quot;>
<cfset Session.SName=#FORM.name#>
</cflock>

<CFINSERT DATASOURCE=&quot;classgrades&quot; TABLENAME=&quot;form1&quot; FORMFIELDS=&quot;name,treatment,qd1,qd2,qd3,qd4,qd5,qd6,qd7,qd8,qd9,qd10,qd11,qd12,qd13,qd14,qd15,qd16,qd17,qd18&quot;>


<cflocation url=&quot;QCcards.htm&quot; addtoken=&quot;no&quot;>


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>

<body>

</body>
</html>

 
How are you passing the cfid and cftoken if you are not using cookies? Are you passing them through the URL? All sessions need an associated cfid and cftoken; otherwise session variables will not work as the CF Server has no clue who they belong to.

-Tek
 
Teknology is right here; cf has to know to what session the client that is requesting the template belongs to; SetClientCookies within the cfapplication tag has to be set to &quot;yes&quot;; even then it is not guaranteed that the session state will work as you don't know if the client has the cookies enabled or not; to ensure state of the session, pass the URLToken with every link you have, e.g.:

<form action=&quot;actionPage.cfm?#client.URLToken#&quot;...

or:

<a href=&quot;actionPage.cfm?#client.URLToken#&quot;... Sylvano
dsylvano@hotmail.com
 
Thank you, thank you...I knew I was making a terrible mistake somewhere.... :)

Thank you very much!.

Kerem
 
Now this is a naive and stupid question but do I need to collect the URL passed tokens in a <cfset> or #URL. # command? Or is it enough to just pass it?
 
just pass it so the template you are passing it to &quot;knows&quot; from where the request came from Sylvano
dsylvano@hotmail.com
 
Well, now I have another weird problem....I am going to lose my mind...This must not be this difficult!!!

Everything works for all the previous pages I use but from one page I make the following link:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFFF&quot; leftmargin=&quot;0&quot; topmargin=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot;>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;june30.cfm?#client.URLToken#&quot;>

blabla


<input name=&quot;treatment&quot; type=&quot;hidden&quot; value=&quot;us1&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Next&quot;>
</form>
</body>
</html>

And I can see that the client.URLToken is passing all necessary IDs etc until the above page. When I click on submit on this page (for the above code) I get


What is wrong with this?

Kerem
 
you need to put a cfoutput around the #client.urltoken# so that coldfusion knows that this is something it has to fill in
 
But, how am I going to put a cfoutput within a form command and I have not been putting that for the previous pages for which it worked...

I am thinking that the problem is due to some html confusion somewhere but I can not see it...

K
 
If it works on the other pages, then you DO have the #client.URLToken# between cfoutput tags. It wouldn't work if you didn't. So just wrap the form tag with opening and closing cfoutput tags.

-Tek
 
Thank you thank you thank you thank you, once and many more again!.

K
 
By now, probably you already hate me... but here is (most probably) my final question.

Ok, now I am able to pass the CFID and CFTOKEN settings to the last page which attempts to call the Session.Name variable I created earlier on the sequence of files I used. Now, How am I going to recover the variable to write to the access file I am using. I just finished the CFID, CFTOKEN URL passes until the last page and I am getting the Session.Name not found error again. I have put '#Session.Name#' in a cfquery call. do I need to call it differently?

Thanks once more
 
Are you sure the CFID and CFTOKEN are getting passed to the page where you write the session variable into the database? I'd try this:

At the top of that page, do: <cfoutput>#client.URLToken#</cfoutput><cfabort>

This will tell you if the cfid and cftoken exist. I am betting that cfid and cftoken are not being passed to that last page. Also, if you are using a cflocation on any of your pages then you should always set the addtoken attribute to YES, since this will automatically include the cfid and cftoken string into the URL.

-Tek
 
Hi,

Well, this is the html link that shows up on every page until the last one:


so I am able to carry the CFID and CFTOKEN either with cflocation which has addtoken set to yes or with a form action call to the related cfm file with cfoutput before and after the form and all with client.URLToken passed on.

I am not touching the #Session.Name# after I use it once in the first form page I use and the very last one which has the same html link above showing up with the related cfm file.
 
This is by the way how I am starting the whole chain

<cflock timeout=&quot;10&quot; throwontimeout=&quot;No&quot; type=&quot;EXCLUSIVE&quot; scope=&quot;SESSION&quot;>
<cfset Session.SName=#FORM.name#>
</cflock>
 
In your last post you used the reference: #Session.SName# but you've been referring to #Session.Name# in your other posts. Maybe this is the problem?

-Tek
 
Hi,

No, sorry, I could not remember exactly which one I used but I am using Session.SName throughout..

K
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top