Solved

Element PREVIOUSPAGE is undefined in SESSION

Posted on 2012-12-26
4
349 Views
Last Modified: 2012-12-27
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
0
Comment
Question by:adam1h
  • 3
4 Comments
 
LVL 39

Expert Comment

by:gdemaria
ID: 38721464
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
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 38722069
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
 

Author Comment

by:adam1h
ID: 38723442
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
 
LVL 39

Expert Comment

by:gdemaria
ID: 38723805
Wow, the hosting company accidently deleted your database!   Glad you survived that!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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

13 Experts available now in Live!

Get 1:1 Help Now