Element PREVIOUSPAGE is undefined in SESSION

Hi Experts,

Our website was running fine (www.joe-cool.co.uk/EN/home/home.cfm. any page that you hit now throws an error that is :

Element PREVIOUSPAGE is undefined in SESSION

application.cfc contains this line :
        <!--- variables to identify pages & urls (for navigation) --->
...
        <cfparam name="Session.previousPage" default="">

...

it crashes here :
...
<cfif Session.previousPage EQ "" OR Session.previousPage EQ "#cgi.script_name#">
                        <cflocation url="#CGI.SERVER_NAME#" addtoken="no">
                  <cfelseif REFind("Element ALLPRODUCTS.PRODUCTS is undefined", arguments.exception.rootcause.message) NEQ 0>
                        <cflocation url="#CGI.SERVER_NAME#" addtoken="no">
                  <cfelse> ...

I don't see why is suddenly happening, no changes have been made to anything.

Pelase help,
Adam
adam1hAsked:
Who is Participating?
 
gdemariaConnect With a Mentor Commented:
The page now errors on undefined TOTALBASKETPRICE

You should define all your session variables in onSessionStart method of your application.cfc file

<cfset session.TOTALBASKETPRICE  = 0>


Tip:  I am not a fan of using session variables to manage your shopping cart, there are too many downsides, I prefer to put the data into the database tables and then just adjust the status of the table to indicate the stage of the order :  in Cart, on Order, processed, shipped, etc...

Keeping the cart in session variables has many disadvantages including:  the cart will completely disappear and the user will have to start over when time-out occurs, you can't easily go from unregistered user's cart to registered user's cart after sign-in (registered users cart gets saved), your customer service cannot see the cart to help a customer on the phone or finish processing the order or apply discounts, etc.  and you have to write twice as much code (you have to write code to manage a session cart and code to manage the order tables).
0
 
gdemariaCommented:
I'm getting a different error:

Could not create connection to database server. Attempted reconnect 3 times. Giving up.
 
The error occurred in D:\inetpub\vhosts\joe-cool.co.uk\httpdocs\model\products_collection.cfc: line 9
Called from D:\inetpub\vhosts\joe-cool.co.uk\httpdocs\Application.cfc: line 462
Called from D:\inetpub\vhosts\joe-cool.co.uk\httpdocs\Application.cfc: line 449
Called from using password: line -1
Called from using password: line -1

7 : 	<cffunction name="init" access="public" output="yes" returntype="model.products_collection">
8 : 		<!--- retrieve products from database (jcstktabl) --->
9 : 		<cfquery name="q" datasource="joecool_web">
10 : 			select * from jcstktabl order by jcid desc
11 : 		</cfquery> 

Open in new window



Regarding your session error, you should have this set in your onSessionStart function of your Application.cfc file:  

<cfset session.previousPage = "">

Although the cfparam should also work, depending on where it is in relationship with your block of code that is throwing the error.   If would, of course, have to be called before it.  Placing the line above in the onSessionStart method would ensure the order of execution.
0
 
adam1hAuthor Commented:
Hi Gdemaria,

Many thanks for your help. The database was deleted by mistake by our hosting company.

We did restart both application and server, recreated the Cfm DSN and it does work fine now.

However, I totally agree with your point of view, this website is old and will soon be replaced by a state of art website, including the arguments you mentionned.

Many thanks
Adam.
0
 
gdemariaCommented:
Wow, the hosting company accidently deleted your database!   Glad you survived that!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.