ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 17th, 2004, 12:13 PM
Le Veilleur Le Veilleur is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 4 Le Veilleur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Session Variables -> Shopping cart

Hi everrybody, i'm new here

So, for one of my course, I must do a website, a shopping website.
For that, I can only used session variables with urltoken and etc... but no cookies. (it's what the prof said)

I've already make the indentification of user, it's done and it works perfectly. But I've a matter with the session variables for the shopping cart. I've read that article URL

My matter is:
In application.cfm

<CFAPPLICATION clientmanagement="Yes" sessionmanagement="Yes" SETCLIENTCOOKIES="NO" SessionTimeout="30">



<cfparam name="session.IsLoggedIn" DEFAULT="No">

<cfparam name="session.login" DEFAULT="non connecté">
<cfparam name="session.panierTab" type="data_type" DEFAULT=arrayNew(1)>


<cfparam name="session.cpt" type="numeric" DEFAULT="0">

</CFAPPLICATION>

In mycart.cfm

<cfset session.cpt=#session.cpt#+1>
<cfset session.panierTab[#session.cpt#]=#url.pro#>
<cfset panierTabTaille=ArrayLen(#session.panierTab#)>


I'm just trying to increment a session variable, session.tmp, but that make error

Element CPT is undefined in SESSION.


The error occurred in E:\WWW\HTTP\cfm\panier.cfm: line 54

52 :
53 :
54 : <cfset session.cpt=#session.cpt#+1>
55 : <cfset session.panierTab[#session.cpt#]=#url.pro#>
56 : <cfset panierTabTaille=ArrayLen(#session.panierTab#)>


I really don't know why... cpt is already defined in session, no?

Thanks for your help

ps: Sorry for my english, i'm belgian

Reply With Quote
  #2  
Old February 17th, 2004, 01:58 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
First of all, you don't need all those pound signs. You only need pound signs when you are outputting a variable for display, or evaluating a dynamic expression. This would work and is cleaner:

<cfset session.cpt = session.cpt + 1 />

You probably want to lock this using <cflock> as this is succeptable to a race condition, but that's another issue.

As to why the variable is not defined, it may be because your code is using the <cfapplication> tag incorrectly. You don't open and close this tag, you should use it without a closing tag.

That should fix the problem of the session variable not being defined. But also know that you will need to pass the session.urlToken in all of your links and form fields if you have cookies disabled (as you do).

Reply With Quote
  #3  
Old February 17th, 2004, 02:43 PM
Le Veilleur Le Veilleur is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 4 Le Veilleur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by kiteless
First of all, you don't need all those pound signs. You only need pound signs when you are outputting a variable for display, or evaluating a dynamic expression. This would work and is cleaner:

<cfset session.cpt = session.cpt + 1 />

You probably want to lock this using <cflock> as this is succeptable to a race condition, but that's another issue.

As to why the variable is not defined, it may be because your code is using the <cfapplication> tag incorrectly. You don't open and close this tag, you should use it without a closing tag.

That should fix the problem of the session variable not being defined. But also know that you will need to pass the session.urlToken in all of your links and form fields if you have cookies disabled (as you do).


Hi thanks, that solve my matter Great

I've other question

I just want to add the product id to my cart, i'm doing that:

<cfset session.cpt=session.cpt+1 />
<cfset session.panierTab[session.cpt]=url.pro/>
<cfset panierTabTaille=ArrayLen(session.panierTab)/>


<cfloop index="i" from="1" to=#panierTabTaille#>
<cfoutput>Affichage ligne[#i#] du panierTab : #ArrayToList(session.panierTab,",")#<br></cfoutput>
</cfloop>

But, I've received the following error

You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.


The error occurred in E:\WWW\HTTP\cfm\panier.cfm: line 55

53 :
54 : <cfset session.cpt=session.cpt+1 />
55 : <cfset session.panierTab[session.cpt]=url.pro />
56 : <cfset panierTabTaille=ArrayLen(session.panierTab) />
57 :

The variable url.pro is the id of my product, which is passing by url parameter.

Thanks for you help

Last edited by Le Veilleur : February 17th, 2004 at 02:47 PM.

Reply With Quote
  #4  
Old February 17th, 2004, 02:54 PM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,480 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 17 h 33 m 17 sec
Reputation Power: 42
If you want to insert and retrieve something based on a "key" such as a product ID, you would need to use a structure instead of an array. Arrays are indexed by number (ie 1, 2, 3, etc.). Structures are referenced by key, which can be a number, a string, etc.

If you want to stick with using an array, you'd simply append the value to the array instead of trying to put it in by the item's ID, like this:

<cfset arrayAppend( session.cpt, url.pro ) />

Reply With Quote
  #5  
Old February 18th, 2004, 02:21 AM
Le Veilleur Le Veilleur is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 4 Le Veilleur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by kiteless
If you want to insert and retrieve something based on a "key" such as a product ID, you would need to use a structure instead of an array. Arrays are indexed by number (ie 1, 2, 3, etc.). Structures are referenced by key, which can be a number, a string, etc.

If you want to stick with using an array, you'd simply append the value to the array instead of trying to put it in by the item's ID, like this:

<cfset arrayAppend( session.cpt, url.pro ) />


My probleme persits

In application.cfm
<cfparam name="session.panierTab" DEFAULT="arrayNew()">

And my cart.cfm


<cflock timeout="30" scope="session">


<cfset session.panierTab = arrayAppend( session.panierTab, structNew() )>
<cfset panierTabTaille=ArrayLen(session.panierTab) />

<cfset session.panierTab[panierTabTaille].pro_id = pro_id>
<cfset session.panierTab[panierTabTaille].pro_marque = pro_marque>
<cfset session.panierTab[panierTabTaille].pro_modele = pro_modele>
<cfset session.panierTab[panierTabTaille].pro_quanti = 1>

<!-- Affichage du panier -->
<cfloop index="i" from="1" to="#arrayLen( session.panierTab )#">
<cfoutput>Affichage ligne[#i#] du panierTab : #ArrayToList(session.panierTab,",")#<br></cfoutput>
</cfloop>
</cflock>


The error

Object of type class java.lang.String cannot be used as an array


The error occurred in E:\WWW\HTTP\cfm\panier.cfm: line 60

58 :
59 :
60 : <cfset session.panierTab = arrayAppend( session.panierTab, structNew() )>
61 : <cfset panierTabTaille=ArrayLen(session.panierTab) />
62 :

I juste make what is write in this article
URL

Thank for helpling me

Reply With Quote
  #6  
Old February 18th, 2004, 04:06 AM
Le Veilleur Le Veilleur is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 4 Le Veilleur User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I fixed my matter

thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Session Variables -> Shopping cart


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway