Welcome!

You will be redirected in 30 seconds or close now.

ColdFusion Authors: Yakov Fain, Jeremy Geelan, Maureen O'Gara, Nancy Y. Nee, Tad Anderson

Related Topics: ColdFusion

ColdFusion: Article

Ask the Training Staff

Ask the Training Staff

We're only two months into 2002 and it's already shaping up to be a very busy year for ColdFusion development. I hope you're experiencing the same thing.

If so, don't forget we're here to help you with all your CF-related issues. This month I have two questions for you.

Q: I'm writing a CF app that needs to interface with another company's shopping cart. A user adds products to our shopping cart and when ready to pay for the products, we send the user to a payment processor for credit-card processing. When the purchase is approved, the payment processor sends the user back to our site using a URL we specify. The problem is this: when the user first comes back to our site, the cart is empty and the session variables seem to be lost. If the user clicks any links within our site again, the cart contents reappear. Any ideas?
A: I've encountered this situation before with an application I wrote for a client a few months ago. The problem is that the payment processor, after processing the transaction, is redirecting the user back to your site using a server-side redirect. Because of this, the user's browser is not sending the CFID and CFTOKEN cookies needed for session management to your site. However, once the user clicks again within your site, these cookies are available to your server. To solve this you need to include the values of CFTOKEN and CFID as part of the URL the cart will send the user back to.

For example, when your user clicks the "Pay" button on your site, you're sending the amount of the purchase and the return URL (e.g., "yoursite.com/return.cfm") over to the other site. When the user completes the transaction, the other site sends him or her back to that URL on your site. Once back on your site, your server doesn't recognize the user because CFID and CFTOKEN are missing. You can fix this by changing the return URL to include that person's session identifiers. Modify your code to create a return URL of "return.cfm?CFID=#Session. CFID#&CFTOKEN=#Session.CFTOKEN#" (all within a CFOUTPUT block, of course). This will put that user's session management values in the URL. When the user returns to your site using that URL, CF will look for these identifiers as cookies or as URL variables. The cookies still won't be there, but the correct values will be in the URL so session management can identify them.

Q: I have a question about your recommendation against copying shared-scope variables into the Request scope (CFDJ, Vol. 3, issue 12). At an Advanced CF course we were told that the duplicate function is very inefficient and resource-intensive, as is using the IIF function. I'm wondering if you've done any testing using the StructCopy function instead. I agree with you that copying information into the Request scope with every page load regardless of whether or not the page requires the data is a poor way to do things. However, why not have two templates, SharedToRequest.cfm and RequestTo-Shared.cfm? They'd contain the code needed to handle the task. You could then include them wherever shared-data access is required. This way you avoid needless memory access and are still able to reap the benefits of accessing variable information without locking.
A: I haven't done any testing on the StructCopy function, but I would avoid using it because it copies only the first level of the structure. Therefore, if you have a structure inside a structure, only the first level is copied. The nested structure is still a pointer.

I like your idea of having SharedToRequest.cfm and Request-ToShared.cfm cfincluded only where you need them. However, you'd still have some issues with the size of the data being copied and the number of people accessing these pages. The bottom line is: while it does take more time to place explicit cflocks around shared data requests, your applications will run faster than if you copy those pieces of data to the request scope before accessing them.

*  *  *

Please send your questions about ColdFusion (CFML, CF Server, or CF Studio) to [email protected]. Visit our archive site at www.netsitedynamics.com/AskCFDJ.

More Stories By Bruce Van Horn

Bruce Van Horn is president of Netsite Dynamics, LLC, a certified ColdFusion developer/instructor, and a member of the CFDJ International Advisory Board.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


IoT & Smart Cities Stories
If a machine can invent, does this mean the end of the patent system as we know it? The patent system, both in the US and Europe, allows companies to protect their inventions and helps foster innovation. However, Artificial Intelligence (AI) could be set to disrupt the patent system as we know it. This talk will examine how AI may change the patent landscape in the years to come. Furthermore, ways in which companies can best protect their AI related inventions will be examined from both a US and...
The challenges of aggregating data from consumer-oriented devices, such as wearable technologies and smart thermostats, are fairly well-understood. However, there are a new set of challenges for IoT devices that generate megabytes or gigabytes of data per second. Certainly, the infrastructure will have to change, as those volumes of data will likely overwhelm the available bandwidth for aggregating the data into a central repository. Ochandarena discusses a whole new way to think about your next...
Charles Araujo is an industry analyst, internationally recognized authority on the Digital Enterprise and author of The Quantum Age of IT: Why Everything You Know About IT is About to Change. As Principal Analyst with Intellyx, he writes, speaks and advises organizations on how to navigate through this time of disruption. He is also the founder of The Institute for Digital Transformation and a sought after keynote speaker. He has been a regular contributor to both InformationWeek and CIO Insight...
Bill Schmarzo, Tech Chair of "Big Data | Analytics" of upcoming CloudEXPO | DXWorldEXPO New York (November 12-13, 2018, New York City) today announced the outline and schedule of the track. "The track has been designed in experience/degree order," said Schmarzo. "So, that folks who attend the entire track can leave the conference with some of the skills necessary to get their work done when they get back to their offices. It actually ties back to some work that I'm doing at the University of ...
DXWorldEXPO LLC, the producer of the world's most influential technology conferences and trade shows has announced the 22nd International CloudEXPO | DXWorldEXPO "Early Bird Registration" is now open. Register for Full Conference "Gold Pass" ▸ Here (Expo Hall ▸ Here)
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time t...
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
The best way to leverage your Cloud Expo presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering Cloud Expo and @ThingsExpo will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at Cloud Expo. Product announcements during our show provide your company with the most reach through our targeted audiences.
The Internet of Things will challenge the status quo of how IT and development organizations operate. Or will it? Certainly the fog layer of IoT requires special insights about data ontology, security and transactional integrity. But the developmental challenges are the same: People, Process and Platform and how we integrate our thinking to solve complicated problems. In his session at 19th Cloud Expo, Craig Sproule, CEO of Metavine, demonstrated how to move beyond today's coding paradigm and sh...
What are the new priorities for the connected business? First: businesses need to think differently about the types of connections they will need to make – these span well beyond the traditional app to app into more modern forms of integration including SaaS integrations, mobile integrations, APIs, device integration and Big Data integration. It’s important these are unified together vs. doing them all piecemeal. Second, these types of connections need to be simple to design, adapt and configure...