Copy link to clipboard
Copied
hi all,
For building a shopping cart, my plan is to use session variables to hold users cart data. And I dont like to use cookies in this app. Can I manage this only with session? Your advise pls....
thanks
A cookie based shopping cart would be quite tricky to implement. Cookies have some notable limitations. They can not store complex data, only simple name and value pairs - complex data would have to be serialized. They have a limited size and a limited number allowed. They can be deleted by users at their whim. To name a few examples.
I would expect a ColdFusion based shopping cart to make use of the ColdFusion data features. Making use of the session, application, and server scopes as well
...Copy link to clipboard
Copied
Yes and no.
Yes the session scope is a fine scope to store user specific data to be used from request to request, like a shopping cart or some part of it.
But for the session scope itself relies on cookies by default. ColdFusion will handle the cookie maintance for you, behinde the scenes. But if your goal is to have an application that does not use cookies, you will have to do something to change how ColdFusion connects session state data to requests received from users.
This is handled by either a two part token, CFID and CFTOKEN, or a more modern singe token, JSESSIONID. By default the token is sent as cookies with every request between the server and the client. ColdFusion then knows what session data goes with what requests by the values of the tokens. If you want to elminate the reliance you have to include the tokin as get data (i.e. URL query string data) with every request. This can take quite a bit of work throughout your application is subject to some risk of session sharing if URL with currenttly valid tokens are shared between users.
HTH
Ian
Copy link to clipboard
Copied
thank you Ian for your good explanation.
In my project, I am going to use array of structures, by which each structure storing product data....so consider, in production environment, suppose there are above 1000 users using my site....that means that much 1000 array of structs are there in server memory, so will it be a problem for my site performance...
please have your thoughts on this too...
thanks..
Copy link to clipboard
Copied
That is a bit harder to say. The only real answer is "It Depends"
It depends on what type and amount of data is stored in those structures. 1 Gigabyte of base 64 encoded image data is going to have a much larger impact then just a simple integer. Even before it is repeated one thousand times or more.
It depends on how much memory your server has.
It depends on how many servers you have and if you care to load balance or not.
It depends on how much memory your ColdFusion|Jrun(or other J2EE) server can be configured to use. I.E. a 32bit server can never address much more then 1.2gigabytes, IIRC. A 64bit server much much more.
It depends on what other uses your server is being put through. Is this shopping cart web site the only application on the server, or are you on a shared hosting server with dozens, hundreds, thousands of other accounts sharing the same server (I would hope not for a shopping application). Or someplace in between.
The only way to really answer the question is to build, load test and adjust based on the testing.
But there are ways you can try to make your data structure more scalable then others. Does all the data need to be stored per user. Or are there parts of the data that is the same for all users. If so, don't repeat what is the same for every user, store it once in a more global way such as the Application or Server scope.
Does all the data need to be in memory all the time. Can some (most?) of the data be stored someplace else, like a database, with only a token or small portion of the user data stored in memory.
HTH
Ian
Copy link to clipboard
Copied
Thanks for the very valued information...
now I got cleared...but just for curiosity, I am asking which is the more popular approach for cart system, is it using fully session approach or with cookies ...just to know only for tat...Suppose a person going to build a free cart application to public, what approach he should use?
anyway thanks for your time...
Copy link to clipboard
Copied
A cookie based shopping cart would be quite tricky to implement. Cookies have some notable limitations. They can not store complex data, only simple name and value pairs - complex data would have to be serialized. They have a limited size and a limited number allowed. They can be deleted by users at their whim. To name a few examples.
I would expect a ColdFusion based shopping cart to make use of the ColdFusion data features. Making use of the session, application, and server scopes as well as database and file system storage. But from these basic, simple assumptions a nearly infinite combination of implementations are possible to best match each individual application's requirements.
Copy link to clipboard
Copied
Very Thanks Ian for your time to share your knowledge.....
Yeah, I am going with server side variables only for this app...hope it will be done nicely..
thanks again..