• Post Reply Bookmark Topic Watch Topic
  • New Topic

Persisting shopping cart values.  RSS feed

 
Shanmugam nagaraj
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Actually I am involved in creating one shopping cart web application. My higher official asked me a requirement like:

Remember the items that the user last browsed - Shows in the front page during each login.

I thinking the solution like:

1) using database we can store the data and retrive it but performance wise it will affect in future.
2) store it in HttpSession but it will available only when the session available. (but I need like even though the customer has logged off if he next time comes and logged in then he can able to see what all are the items he browsed last time.)
3) I also thought like about cookies, but not sure about that.


Question is like this:
I need to know is this three ways only available.
Is there any thing else apart from this way. If there means what all are the ways?
And give me the solution for the problem(with code if possible pls pls..)

Thanks

Shanmugam
[ May 30, 2007: Message edited by: Ben Souther ]
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the kind of requirement you have , I think persistence is the only way.

I will go with it , if you want to show the objects selected by the user on login each time.
 
Sherlock Yao
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's certain that you should store the data (the items user last browsed) in somewhere , then you can retrieve the data when the user login again.
So ,IMO, you can store the data either in server side (using databases or files) or in client side (using cookies).
But using cookies could not guarantee the requirement while the users can disable the cookies in the browse.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And cookies will have a size restriction.So it also matters as how much amount of data would you be storing in client side(Considering cookies are not disabled).

You might want to store all the details about the item that the user wants to buy.That might make the data to be stored a big chunk.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might want to store all the details about the item that the user wants to buy.

That would be an unusual approach. It should just be the bare minimum - product ID and quantity for each item in the cart. All other details should be retrieved from the database when the customer returns. So I don't think data size is a criterium here - it's negligible.
[ May 27, 2007: Message edited by: Ulf Dittmer ]
 
Shanmugam nagaraj
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
So what and which is right way I have to approach for this issue.
Ulf Dittmer has given one good idea that we can store the product id and count in the cookies, Is this gurantee in future, So there is any other way or I can say it is not possible to my higher officials..

Pls let me know about this issue

And thanks for your great response....

bye

Shanmugam..
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Shanmugam nagaraj:

Ulf Dittmer has given one good idea that we can store the product id and count in the cookies


Certainly storing some information is possible as Ulf suggested.
But what when the client is using client with cookies disabled.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I didn't say anything about cookies. I was talking about data size, independent of any storage mechanism, be it a database, a file, or a cookie. Which of these is most appropriate really depends on the circumstances of your application, about which we know nothing.

Of course, if there is no cookie, the user won't be recognized the next he returns anyway. Unless a registration/login process is involved, to which users generally won't sign up unless they're positive they're getting value out of it.
[ May 27, 2007: Message edited by: Ulf Dittmer ]
 
Pravin Jain
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To me Sherlock Yao's idea is the best.
We cannot guarantee the feature in case
the user disables cookies, we might ask
the user to keep cookies enabled if he
wants to use the feature.
 
Charles Rhinehart
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ihmo:

In the past I have stored the data in the session, and created a session listener to save the data to the user's profile in the database when the session is about to expire.

When the user logged back in to the system I would restore the data to the session.

I'm assuming that you're using "sticky sessions" to keep the user on the same server / session?
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:

Of course, if there is no cookie, the user won't be recognized the next he returns anyway. Unless a registration/login process is involved, to which users generally won't sign up unless they're positive they're getting value out of it.


Registration / login process is there in the application as mentioned in the initial post.So why to store information in the cookies , it can be stored in databases and as soon as the user logs into the application , the cart in the session might be populated with all the previously selected items.



Charles Rhinehart : I'm assuming that you're using "sticky sessions" to keep the user on the same server / session?


I think sticky session has to do with application deployed in cluster where do minimize the effort of session passivation and activation , you redirect the request to client to the same node.
correct me if I am wrong.
 
Charles Rhinehart
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...you redirect the request to client to the same node.


That's correct. If you weren't using "sticky sessions" then my answer would have been different in that case:

e.g. Share Nothing Architecture

(edit: memcached)

[ May 28, 2007: Message edited by: Rhinehart ]
[ May 28, 2007: Message edited by: Rhinehart ]
 
rahul khanna
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, If I am correct , cookies will only work for a machine i.e on a PC/IPAddress specific. What if the user is logging using a different machine 2nd time. In that case , it is not possible to retrieve the data using cookies. The best possible way is to persist the data in the DB.

When the user logs in , you are anyways hitting the DB to retrieve the users login credentials , during the same hit you can also retrieve the product selected/browsed information thus keeping the overhead to a minimum.

Cheers
 
Shanmugam nagaraj
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Great .....
At last we come to the conclusion we can store those things in the database, Actually I planned like to store the item which was selected by user and store it in the string buffer as concatenated like:
eg :
if the customer chose like edroman, j2ee, head first books.
I will store using string buffer like
stringBuffer strb="edroman+j2ee+headfirst";

store this string to the database and
retrive it using the string tokenizer is it right way which I thought or any other suggestion you have....


Thanks for your's valuable response......
 
Girish M S
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I prefer to use file on server side instead of DB. Think there are only 3 ways as you mentioned to achieve it.

Wish you Good luck
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by G M S James:
Yes, I prefer to use file on server side instead of DB. Think there are only 3 ways as you mentioned to achieve it.


As this would be a commercial application , few points might be worth noting.

  • File system would not support query , so retrieving the data from the file might be tedious.Even though the format is simple enough.
  • Backup might be an issue.
  • admin application based on the file might be difficult to write for the same reason of queries.

  •  
    Raghavan Muthu
    Ranch Hand
    Posts: 3389
    Mac MySQL Database Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Shanmugam,

    Thats a good idea what everyone else has poured in. Of course, you need to be a bit cautious before taking a decision. Cookies is of that sort. Also what if the user logs in a different machine the next time?

    Why dont you consider storing it in a file on the server side rather than database? You can for serialization and deserialization right. I think it may have some performance improvements. Isnt it?

    But as Ulf said, you gonna store the keywords or keys in the persistent storage (lets say, into a file) and then again you need to get in touch with the database to retrieve all other associated details. In that case, better you can store it in the database itself. That seems to be a good choice according to me.
     
    Raghavan Muthu
    Ranch Hand
    Posts: 3389
    Mac MySQL Database Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Rahul,


    File system would not support query ...


    You stole my words...
     
    Rahul Bhattacharjee
    Ranch Hand
    Posts: 2308
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Raghavan Muthu:
    You stole my words...


    Yes , I have.
     
    Shanmugam nagaraj
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi all,
    Thanks thanks thanks......for your worthable informations..
    and I implemented as I mentioned and tomr. is the presentation for me ok..

    Really you all helped me a lot thanks for that again. And meet you with another difficult question... be ready,.....and be alert..

    thanks

    Shanmugam ,
     
    Shanmugam nagaraj
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi all,
    Thanks thanks thanks......for your worthable informations..
    and I implemented as I mentioned and tomr. is the presentation for me ok..

    Really you all helped me a lot thanks for that again. And meet you with another difficult question... be ready,.....and be alert..

    thanks

    Shanmugam ,
     
    Shanmugam nagaraj
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi all,
    Thanks thanks thanks......for your worthable informations..
    and I implemented as I mentioned and tomr. is the presentation for me ok..

    Really you all helped me a lot thanks for that again. And meet you with another difficult question... be ready,.....and be alert..

    thanks

    Shanmugam ,
     
    Shanmugam nagaraj
    Ranch Hand
    Posts: 76
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi all,
    Thanks thanks thanks......for your worthable informations..
    and I implemented as I mentioned and tomr. is the presentation for me ok..

    Really you all helped me a lot thanks for that again. And meet you with another difficult question... be ready,.....and be alert..

    thanks

    Shanmugam ,
     
    Raghavan Muthu
    Ranch Hand
    Posts: 3389
    Mac MySQL Database Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    shanmugam you dont need to alert us thrice
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Posts: 66158
    146
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    "G M S",

    There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

    In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

    Thanks!
    bear
    JavaRanch Sheriff
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!