?
Solved

Woes w/Sessions

Posted on 2003-02-19
10
Medium Priority
?
193 Views
Last Modified: 2013-12-24
Sessions are not acting as anticipated.
When I go to step 2 then, return to step 1 my entries in step 1 are gone. What am I doing wrong?

<!--- File: application.cfm
        Author: Rob A.
--->      
<!--- Any variables set here can be used by all our pages --->
<CFSET DataSource  = "groupsales">

<!--- Name our app, and enable Client and Application vars --->
<CFAPPLICATION
  NAME="TktWiz"
  SESSIONMANAGEMENT="Yes"
  sessiontimeout="#CreateTimeSpan(0,0,45,0)#"
  setclientcookies="NO">

<CFCOOKIE name="CFID" value="#SESSION.CFID#">
<CFCOOKIE name="CFTOKEN" value="#SESSION.CFTOKEN#">


<!---
  Filename:     wizard.cfm
  by:                   Rob A
--->

<!--- Total Number of Steps in the Wizard --->
<CFSET NumberOfSteps = 3>

<!--- The SESSION.TktWiz structure holds users' entries --->
<!--- as they move through wizard. Make sure it exists! --->
<CFIF (NOT IsDefined("SESSION.TktWiz")) OR (NOT IsDefined("URL.StepNum"))>
  <!--- If structure undefined, create/initialize it --->
  <CFSET SESSION.TktWiz = StructNew()>
  <!--- Represents current wizard step; start at one --->
  <CFSET SESSION.TktWiz.StepNum = 1>
  <!--- We will collect these from user; start blank --->
  <CFSET SESSION.TktWiz.FName  = "">
  <CFSET SESSION.TktWiz.LName   = "">
  <CFSET SESSION.TktWiz.phone  = "">
  <CFSET SESSION.TktWiz.extension = ""> 
  </CFIF>


<!--- If user just submitted information, remember it --->
<CFIF IsDefined("Form.TktWiz")>
  <CFSET SESSION.TktWiz.FName = Form.FName>
  <CFSET SESSION.TktWiz.LName = Form.LName>
  <CFSET SESSION.TktWiz.phone = Form.phone>
  <CFSET SESSION.TktWiz.phone = Form.extension>

  </CFIF>


<!--- If user clicked "Back" button, go back a step --->
<CFIF IsDefined("Form.GoBack")>
  <CFSET SESSION.TktWiz.StepNum = URL.StepNum - 1>
<!--- If user clicked "Next" button, go forward one --->
<CFELSEIF IsDefined("Form.GoNext")>
  <CFSET SESSION.TktWiz.StepNum = URL.StepNum + 1>
<!--- If user clicked "Finished" button, we're done --->
<CFELSEIF IsDefined("Form.GoDone")>
  <CFLOCATION URL="NewTktCommit2.cfm">
</CFIF>


<HTML>
<HEAD><TITLE>Group Registration Wizard</TITLE></HEAD>
<BODY>

<!--- Show title and current step --->
<CFOUTPUT>
  <H1>Group Registration Wizard</H1><BR>
  <p>Step #SESSION.TktWiz.StepNum# of #NumberOfSteps#</p><BR>
</CFOUTPUT>


<!--- Data Entry Form, which submits back to itself --->
<CFFORM
  ACTION="wizard.cfm?StepNum=#SESSION.TktWiz.StepNum#"
  METHOD="POST">
 
  <!--- Display the appropriate wizard step --->
  <CFSWITCH EXPRESSION="#SESSION.TktWiz.StepNum#">
    <!--- Step One: Contact Information --->
    <CFCASE VALUE="1">
      <!--- Get potential counties from database --->
        <cfquery name="GetCounty" datasource="schoolgroups">
        SELECT *
        FROM Counties
        </cfquery>
        <!--- Get potential states from database --->
      <cfquery name="GetState" datasource="schoolgroups">
      SELECT *
      FROM abbrStates
      </cfquery>
      <!--- get todays date and hide it use as date entered --->
        <INPUT
         TYPE="hidden"
         NAME="dateEntered"
         VALUE="<cfoutput>#Now()#</cfoutput>">
      <!--- Show text entry field for first name --->
      <P>What is your first name?<BR>
      <CFINPUT
        NAME="FName"
        SIZE="25"
        REQUIRED="Yes"
        MESSAGE="Please don't leave your first name blank."
        VALUE="#SESSION.TktWiz.FName#">

      <!--- Show text entry field for last name --->
      <P>What is your last name?<BR>
      <CFINPUT
        NAME="LName"
        SIZE="50"
        REQUIRED="Yes"
        MESSAGE="Please don't leave your last name blank."
        VALUE="#SESSION.TktWiz.LName#">
        <P>What is your phone number?<BR>
        <cfinput
            name="phone"
            type="text"
            validate="telephone"
            id="phone"
            REQUIRED="Yes"
        MESSAGE="Please enter your phone number."
            value="#SESSION.TktWiz.Phone#">
            
            <P>What is your extension?<BR>
        <cfinput
            name="extension"
            type="text"
            id="extension"
            value="#SESSION.TktWiz.extension#">
       
 

   
   
    <!--- Step Three: Final Confirmation --->
    <CFCASE VALUE="3">
      You have successfully finished the New Ticket Registration Wizard.<BR>
      Click the Finish button to confirm your registration.<BR>
      Click Back if you need to change anything.<BR>
    </CFCASE>  
  </CFSWITCH>
 

  <P>
  <!--- Show Back button, unless at first step --->  
  <CFIF SESSION.TktWiz.StepNum GT 1>
    <INPUT TYPE="Submit" NAME="GoBack" VALUE="&lt;&lt; Back">
  </CFIF>  
  <!--- Show Next button, unless at last step --->
  <!--- If at last step, show "Finish" button --->
  <CFIF SESSION.TktWiz.StepNum LT NumberOfSteps>
    <INPUT TYPE="Submit" NAME="GoNext" VALUE="Next &gt;&gt;">
  <CFELSE>
    <INPUT TYPE="Submit" NAME="GoDone" VALUE="Finish">
  </CFIF>
</CFFORM>

</BODY>
</HTML>
0
Comment
Question by:RobA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 9

Expert Comment

by:HamdyHassan
ID: 7982769
Try the following

<CFAPPLICATION
 NAME="TktWiz"
 sessionmanagement="Yes"
 clientmanagement="Yes"
 setclientcookies="Yes"
 clientstorage="REGISTRY"
 sessiontimeout="#CreateTimeSpan(0,0,45,0)#"
>
0
 
LVL 9

Expert Comment

by:HamdyHassan
ID: 7982805
Also when you set the session var, you need a lock

<CFLOCK timeout="30" scope="session" type="exclusive" >

 <CFSET SESSION.TktWiz.FName  = "">
 <CFSET SESSION.TktWiz.LName   = "">
 <CFSET SESSION.TktWiz.phone  = "">
 <CFSET SESSION.TktWiz.extension = ""> 

</CFLOCK>


and when you read it, you need another lock

<CFLOCK timeout="30" scope="session" type="readonly" >
     <CFIF ISDEFINED("SESSION.PRODUCT_ID")>
          <CFSET default_product_id = SESSION.PRODUCT_ID >     
     </CFIF>
</CFLOCK>
0
 

Expert Comment

by:eriklee
ID: 7991932
possibly because u said

setclientcookies='No'..
0
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 

Expert Comment

by:pgobos
ID: 7994170
I tried the following code changes suggested by Hamdy as well as the application changes and it still does not work.

Hamdy did you test this code?



<CFLOCK timeout="30" scope="session" type="exclusive" >

 <CFSET SESSION.TktWiz.FName  = "">
 <CFSET SESSION.TktWiz.LName   = "">
 <CFSET SESSION.TktWiz.phone  = "">
 <CFSET SESSION.TktWiz.extension = ""> 
</CFLOCK>

<!--- If user just submitted information, remember it --->
 
<CFLOCK timeout="30" scope="session" type="readonly" >
<CFIF IsDefined("Form.TktWiz")>
 <CFSET SESSION.TktWiz.FName = Form.FName>
 <CFSET SESSION.TktWiz.LName = Form.LName>
 <CFSET SESSION.TktWiz.phone = Form.phone>
 <CFSET SESSION.TktWiz.phone = Form.extension>
 </CFIF>
 </CFLOCK>
0
 

Author Comment

by:RobA
ID: 7994703
I tried making the appliaction changes and it didn't work.


<!--- Any variables set here can be used by all our pages --->
<CFSET DataSource  = "groupsales">

<!--- Name our app, and enable Client and Application vars --->
<CFAPPLICATION
  NAME="TktWiz"
  SESSIONMANAGEMENT="Yes"
  setclientcookies="Yes"
  clientstorage="REGISTRY"
  sessiontimeout="#CreateTimeSpan(0,0,45,0)#">

<CFCOOKIE name="CFID" value="#SESSION.CFID#">
<CFCOOKIE name="CFTOKEN" value="#SESSION.CFTOKEN#">

0
 
LVL 9

Expert Comment

by:HamdyHassan
ID: 7995581
If you run coldfusion on unix, then registry won't work.

Please check coldfusion admin to setting
SESSIONMANAGEMENT and clientmanagement


pgobos :
for sure it's working for me.


The only thing somebody need to investigate about setting cookie CFID and CFTOKEN , when we can do that ? and where we should put this code?

0
 

Expert Comment

by:pgobos
ID: 7998558
Strange I am using Windows 2000 and can't seem to get it to work.  It looks like RobA used a Ben Forta example to run this code .
 The Ben Forta example runs fine and I thought I traced threw it comparing both.

I still cannot find the error in this code.

I do not think CFID and CFTOKEN  tags are even needed in this example.
0
 

Author Comment

by:RobA
ID: 8008314
To Clarify, the "problem" I see is this:

When I submit the info for Step 1 then, goto Step 2 two different things can happen:

1) Click the browser's back button: Step 1 displays previously entered info.

2) Click the application back button: Step 1 is empty.

Is this expected? I would have thought that the application back button would behave similarily to the browser back button?

My perspective/opinion is that you show the user what they entered and change only what is necessary. Not force the user to re-enter ALL the information in the previous step.
0
 

Author Comment

by:RobA
ID: 8064621
So.. is this really a problem or the usual behavior?
0
 
LVL 10

Accepted Solution

by:
substand earned 160 total points
ID: 8076677
it would be the usual behavior, since the browser is involved.
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

752 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