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:
  #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 Specialist (4000 - 4499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 4,084 kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 10 h 42 m 46 sec
Reputation Power: 780
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 Specialist (4000 - 4499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 4,084 kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level)kiteless User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 10 h 42 m 46 sec
Reputation Power: 780
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!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT