Solved

undefined session variable...shuld be defined as i define it in my code

Posted on 2004-09-12
6
182 Views
Last Modified: 2013-12-24
I get the following error

Element USER.CART.SHIPPINGMETHOD2 is undefined in SESSION.  
 
 
The error occurred in C:\CFusionMX\wwwroot\Andysite\login.cfm: line 720
Called from C:\CFusionMX\wwwroot\Andysite\login.cfm: line 682
Called from C:\CFusionMX\wwwroot\Andysite\login.cfm: line 1
 
718 :                       <cfset estDate = dateAdd("d",getSelectedShipping.shippingdays ,now())>
719 :                         
720 :                           <b class="labelstrong">Shipping Method:</b> <font class="label">#getSelectedShipping.shippingname# #dollarFormat(session.user.cart.shippingMethod2)#</font><br/>
721 :                       <b class="labelstrong">Estimated Arrival Date:</b>  <font class="label">#dateFormat(session.user.cart.shippingMethod3,
722 :                               'mmm dd, yyyy')#</font>

 ******************************************************
THE CODE IS BELOW THAT GENERATES THE ERROR, NOTICE I ALREADY DEFINE session.user.cart.shippingMethod2 in the code BEFORE!! i call it

*******************************************************
<TABLE cellspacing=0 cellpadding=0 width=779 align=right bgcolor=#efefef
border=0>
  <!--DWLayoutTable-->
  <TBODY>
    <TR>
      <TD height="18" colspan=6>
<cfsilent>
<cfparam name="url.step" default="1">      
<cfparam name="form.step" default="#url.step#">
<cfif isDefined("form.continue_submit") or isDefined ("form.hideme")>
      <cfscript>
            if( form.step eq 1 )
            {
                  if( form.type eq "returning" )
                  {
                        status = session.user.login( email=form.email, password=form.password );
                        if( variables.status )
                        {
                              //login successfull, continue with checkout
                              form.step = 2;
                        }else if( not variables.status ){
                              //login unsuccessful
                              errorMessage = "Login unsuccessful, try again";
                              form.step = 1;
                        }
                  }else if( form.type eq "new" )
                  {
                        status = session.user.checkEmail( email=form.email );
                        if( not variables.status ){
                              //no existing account that matches the email/password
                              session.user.email = form.email;
                              session.user.password = form.password;
                              // need to manually clear out all user info in case they already logged in but decided to create a new user
                              session.user.billing.firstname = "";
                              session.user.billing.lastname = "";
                              session.user.billing.givenname = "";
                              session.user.billing.familyname = "";
                              session.user.phone1 = "";      
                              session.user.billing.street1 = "";
                              session.user.billing.street2 = "";
                              session.user.billing.city = "";
                              session.user.billing.state = "";
                              session.user.billing.zipcode = "";
                              session.user.billing.country = "";
                              session.user.shipping.firstname = "";
                              session.user.shipping.lastname = "";
                              session.user.shipping.street1 = "";
                              session.user.shipping.street2 = "";
                              session.user.shipping.city = "";
                              session.user.shipping.state = "";
                              session.user.shipping.zipcode = "";
                              session.user.shipping.country = "";
                              session.user.cart.shippingMethod = "3";
                              session.user.cart.shippingMethod2 = "077";
                              session.user.creditcard.type = "";
                              session.user.creditcard.number = "";
                              session.user.creditcard.expiration = "";
                              //
                              form.step = 2;
                        }else if( variables.status ){
                              //account already exists,
                              errorMessage = "account already exists, login in as a returning user instead.";
                              form.step = 1;
                        }
                  }

            }else if( form.step eq 2 ) {
                  session.user.familyname = form.lastname;
                  session.user.givenname = form.firstname;
                  session.user.phone1 = form.phone;            
                  //session.user.email = form.email;
                  
                  session.user.billing.firstname = form.firstname;
                  session.user.billing.lastname = form.lastname;
                  session.user.billing.street1 = form.street1;
                  session.user.billing.street2 = form.street2;
                  session.user.billing.city = form.city;
                  session.user.billing.state = form.state;
                  session.user.billing.zipcode = form.zipcode;
                  session.user.billing.country = form.country;
                  
                  if( isDefined("form.shippingSameAsBilling") )
                  {
                        session.user.shipping.firstname = form.firstname;
                        session.user.shipping.lastname = form.lastname;
                        session.user.shipping.street1 = form.street1;
                        session.user.shipping.street2 = form.street2;
                        session.user.shipping.city = form.city;
                        session.user.shipping.state = form.state;
                        session.user.shipping.zipcode = form.zipcode;
                        session.user.shipping.country = form.country;
                  }
                  
                  form.step = 3; //set was successful move to next step

            }else if( form.step eq 3 ) {
                  session.user.shipping.firstname = form.firstname;
                  session.user.shipping.lastname = form.lastname;
                  session.user.shipping.street1 = form.street1;
                  session.user.shipping.street2 = form.street2;
                  session.user.shipping.city = form.city;
                  session.user.shipping.state = form.state;
                  session.user.shipping.zipcode = form.zipcode;
                  session.user.shipping.country = form.country;
                  
                  form.step = 4; //set was successful move to next step
                  
            }else if( form.step eq 4  and form.hideme eq 2 ) {
                  session.user.cart.shippingMethod = form.shippingMethod;

                  form.step = 4; //set was successful move to next step}
            }else if( form.step eq 4  and form.hideme eq 0) {
                  session.user.cart.shippingMethod = form.shippingMethod;
                  session.user.cart.shippingMethod2 = form.hideme2;
                  session.user.cart.shippingMethod3 = form.hideme3;
                  
                  form.step = 5; //set was successful move to next step}
            }else if( form.step eq 5 ) {
                  session.user.creditcard.type = form.ccType;
                  session.user.creditcard.number = form.ccNumber;
                  session.user.creditcard.expiration = "#form.ccExpMonth#/#form.ccExpYear#";
                  session.user.creditcard.expiration1 = "#form.ccExpMonth##form.ccExpYear#";
                  session.user.cart.taxme = "0.00";
                  status = session.user.placeorder2(session.user.shipping.city,session.user.shipping.street1,session.user.shipping.state,session.user.shipping.country,session.user.shipping.firstname,session.user.shipping.lastname,session.user.phone1,session.user.shipping.zipcode,session.user.shipping.lastname,session.user.creditcard.number,session.user.creditcard.expiration1, session.user.cart.getCartTotal(), session.user.cart.taxme, session.user.cart.shippingMethod2, session.user.email, session.user.billing.city,session.user.billing.street1,session.user.billing.state,session.user.billing.country,session.user.billing.firstname,session.user.billing.firstname,session.user.billing.firstname,session.user.billing.zipcode);
                  
                  form.step = 6; //set was successful move to next step
                  
            }else if( form.step eq 6 ) {
                  status = session.user.placeorder(session.user.shipping.city,session.user.shipping.street1,session.user.shipping.state,session.user.shipping.country,session.user.shipping.firstname,session.user.shipping.lastname,session.user.phone1,session.user.shipping.zipcode,session.user.shipping.lastname,session.user.creditcard.number,session.user.creditcard.expiration1, session.user.cart.getCartTotal(), session.user.cart.taxme, session.user.cart.shippingMethod2, session.user.email, session.user.billing.city,session.user.billing.street1,session.user.billing.state,session.user.billing.country,session.user.billing.firstname,session.user.billing.firstname,session.user.billing.firstname,session.user.billing.zipcode,session.user.cart.shippingMethod);
                  
                  //set was successful set message text.
                  if( status )
                  {
                        form.step = 7;
                  }else {
                        statusmessage = "There was an error placing your order, please try again.<br>If the problem continues please call our 800 customer service number.<br>Thank You.";
                        form.step = 6;
                  }

                  
            }
            
      </cfscript>
      </cfif>




<cfquery name="getShippingMethods" datasource="#application.datasource#" cachedwithin="#createTimeSpan(1,0,0,0)#">
      select shippingoid, upsvalue, shippingname, shippingdescription, shippingprice, shippingdays
      from shippingmethod
      order by shippingprice
</cfquery>

<cfquery name="getStateList" datasource="#application.datasource#" cachedwithin="#createTimeSpan(1,0,0,0)#">
      select distinct state
      from zip
      order by statename
</cfquery>




</cfsilent>

<cfoutput>&nbsp;
            <b class="labelstrong">1) <cfif form.step gt 1 and form.step lt 7><a href="#cgi.script_name#?step=1"></cfif>Login</a></b>      &nbsp;
            <b class="labelstrong">2) <cfif form.step gt 2 and form.step lt 7><a href="#cgi.script_name#?step=2"></cfif>Customer Details / Billing Address</a></b>
            <table border="0" cellpadding="10" cellspacing="0" width="100%">
              <tr>
                    <td><font class="label">
                          #session.user.givenname# #session.user.familyname# <br />
                          #session.user.email# <br />
                          <cfif len(session.user.phone1)>#session.user.phone1# <br /></cfif>
                          <cfif len(session.user.billing.street1)>#session.user.billing.street1#<br /></cfif>
                          <cfif len(session.user.billing.street2)>#session.user.billing.street2#<br /></cfif>
                          #session.user.billing.city# / #session.user.billing.state# / #session.user.billing.zipcode#<br />
                          </font>
                    </td>
              </tr>
            </table>
            <b class="labelstrong">&nbsp; 3) <cfif form.step gt 3 and form.step lt 7><a href="#cgi.script_name#?step=3"></cfif>Shipping Address</a></b>
            <table border="0" cellpadding="10" cellspacing="0" width="100%">
              <tr>
                    <td colspan="2"><font class="label">
                          #session.user.shipping.firstname# #session.user.shipping.lastname# <br />
                          <cfif len(session.user.shipping.street1)>#session.user.shipping.street1#<br /></cfif>
                          <cfif len(session.user.shipping.street2)>#session.user.shipping.street2#<br /></cfif>
                          #session.user.shipping.city# / #session.user.shipping.state# / #session.user.shipping.zipcode#<br /></font>
                    </td>
              </tr>
            </table>
            <b class="labelstrong">&nbsp; 4) <cfif form.step gt 4 and form.step lt 7><a href="#cgi.script_name#?step=4"></cfif>Shipping Options</a></b>
            <table border="0" cellpadding="10" cellspacing="0" width="100%">
              <tr>
                <td>
                          <cfquery name="getSelectedShipping" dbtype="query">
                                select shippingoid, shippingname, shippingdescription, shippingprice, shippingdays
                                    from getShippingMethods
                                    where upsvalue = #session.user.cart.shippingMethod#
                          </cfquery>
                      <cfset estDate = dateAdd("d",getSelectedShipping.shippingdays ,now())>
                        
                          <b class="labelstrong">Shipping Method:</b> <font class="label">#getSelectedShipping.shippingname# #dollarFormat(session.user.cart.shippingMethod2)#</font><br/>
                      <b class="labelstrong">Estimated Arrival Date:</b>  <font class="label">#dateFormat(session.user.cart.shippingMethod3,
                              'mmm dd, yyyy')#</font>
                    </td>
              </tr>
            </table>
0
Comment
Question by:finnstone
6 Comments
 
LVL 21

Expert Comment

by:pinaldave
ID: 12041212
This is strange.
I am not sure what is the error but we can try few things.
1) try to remove cfsilent and run the code
2) try to put session.ur.car.shippingmethod2 = 077 instead of "077"
3) try this number format which is like this ... #numberformat(session.user.cart.shippingMethod2, "$____.__")#

regards,
---Pinal
0
 
LVL 10

Expert Comment

by:Mause
ID: 12041511

use CFDUMP to see if CART.SHIPPINGMETHOD2 realy is defined in session.user

Mause
0
 
LVL 17

Accepted Solution

by:
anandkp earned 500 total points
ID: 12041541
are u sure its getting initialised - as its inside a "if--else" condition block ... just a thought !
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 35

Expert Comment

by:mrichmon
ID: 12047174
or use a cfparam to set a default value and then if you see the default value you know it wasn't set
0
 
LVL 9

Expert Comment

by:Jerry_Pang
ID: 12072043
what is the value of form.step?

step 1 & new
set

step 1 & returning
not set

step 2
not set

step 3
not set

step 4 & hideme=2
set

step 4 & hideme=0
notset

....
not set
the only way shippingmethod is set is through
step 1 new or step 4 hideme=2

are you sure it started with step one and new (not returning?)

to be sure, just initialize all the session.user before you start.
use cfparam as they suggested or initialize everything on the start of the code.

0
 

Author Comment

by:finnstone
ID: 12077347
the steps are used this code which is immediately after the code already posted (notice a different page is loaded depeding on step #)


<tr>
      <td bgcolor="#iif(form.step gt 3, de("ddddcc"), de("ffee99"))#" height="18">
            <b class="labelstrong">&nbsp; 3) <cfif form.step gt 3 and form.step lt 7><a href="#cgi.script_name#?step=3"></cfif>Shipping Address</a></b>
      </td>
</tr>
<cfif form.step eq 3>
      <cfinclude template="_checkout_step3.cfm">

<cfelseif form.step gt 3 and form.step lt 6>
<tr bgcolor="fffff0">
      <td>
            <table border="0" cellpadding="10" cellspacing="0" width="100%">
                  <tr>
                        <td colspan="2"><font class="label">
                              #session.user.shipping.firstname# #session.user.shipping.lastname# <br />
                              <cfif len(session.user.shipping.street1)>#session.user.shipping.street1#<br /></cfif>
                              <cfif len(session.user.shipping.street2)>#session.user.shipping.street2#<br /></cfif>
                              #session.user.shipping.city# / #session.user.shipping.state# / #session.user.shipping.zipcode#<br /></font>
                        </td>
                  </tr>
            </table>
      </td>
</tr>
</cfif>




<tr>
      <td bgcolor="#iif(form.step gt 4, de("ddddcc"), de("ffee99"))#" height="18">
            <b class="labelstrong">&nbsp; 4) <cfif form.step gt 4 and form.step lt 7><a href="#cgi.script_name#?step=4"></cfif>Shipping Options</a></b>
      </td>
</tr>
<cfif form.step eq 4>
      <cfinclude template="_checkout_step4.cfm">
<cfelseif form.step gt 3 and form.step lt 6>
<tr bgcolor="fffff0">
      <td>
            <table border="0" cellpadding="10" cellspacing="0" width="100%">
                  <tr>
                    <td>
                              <cfquery name="getSelectedShipping" dbtype="query">
                                    select shippingoid, shippingname, shippingdescription, shippingprice, shippingdays
                                    from getShippingMethods
                                    where upsvalue = #session.user.cart.shippingMethod#
                              </cfquery>
                          <cfset estDate = dateAdd("d",getSelectedShipping.shippingdays ,now())>
                        
                              <b class="labelstrong">Shipping Method:</b> <font class="label">#getSelectedShipping.shippingname# #dollarFormat(session.user.cart.shippingMethod2)#</font><br/>
                          <b class="labelstrong">Estimated Arrival Date:</b>  <font class="label">#dateFormat(session.user.cart.shippingMethod3,
                              'mmm dd, yyyy')#</font>
                        </td>
                  </tr>
            </table>
      </td>
</tr>
</cfif>




<tr>
      <td bgcolor="#iif(form.step gt 5, de("ddddcc"), de("ffee99"))#" height="18">
            <b class="labelstrong">&nbsp; 5) <cfif form.step gt 5 and form.step lt 7><a href="#cgi.script_name#?step=5"></cfif>Payment Method</a></b>
      </td>
</tr>
<cfif form.step eq 5>
      <cfinclude template="_checkout_step5.cfm">
<cfelseif form.step gt 4 and form.step lt 6>
<tr bgcolor="fffff0">
      <td>
            <table border="0" cellpadding="10" cellspacing="0" width="100%">
                  <tr>
                        <td colspan="2">
                              <b class="labelstrong">Credit Card Type:</b> #session.user.creditcard.type# <br />
                              <b class="labelstrong">Number:</b> #session.user.creditcard.number# <br />
                              <b class="labelstrong">Expiration Date:</b> #session.user.creditcard.expiration# <br />
                        </td>
                  </tr>
            </table>
      </td>
</tr>

</cfif>



<tr>
      <td bgcolor="#iif(form.step gt 6, de("ddddcc"), de("ffee99"))#" height="18">
                  <b class="labelstrong">&nbsp; 6) Confirmation</b>
      </td>
</tr>
<cfif form.step eq 6>
      <cfinclude template="_checkout_step6.cfm">
</cfif>

<tr>
      <td bgcolor="ffee99" height="18">
            <b class="labelstrong">&nbsp; 7) Receipt</b>
      </td>
</tr>
<cfif form.step eq 7>
<tr bgcolor="ffffcc">
      <td>
            <table border="0" cellpadding="10" cellspacing="0" width="100%">
                  <tr>
                        <td align="center"><font class="label" face="Arial,geneva,helvetica,sans-serif" size="2">
                        <br /><br />                  
                              Your order has been placed successfully.
                        <br /><br />
                        </font>
                        </td>
                  </tr>
            </table>      
      </td>
</tr>

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

20 Experts available now in Live!

Get 1:1 Help Now