It's not a secret anymore!
The moose likes Servlets and the fly likes Session within session Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Session within session" Watch "Session within session" New topic
Author

Session within session

Ashish Malik
Ranch Hand

Joined: Jul 11, 2010
Posts: 50
I need to implement a shopping cart in my app. Its only allowed for registered logged in users.

So a user logs in and may shop or do other stuff...so i need to maintain a user's session and a shopping cart session within that session.
And when user checks out ...he doesnt get logged off...i mean when shopping cart session gets invalidated....user session is still preserved!

Any help...
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

The way I see it here, there is actually only one session. Inside that session, you may store information about the user and also the shopping cart information. When the user checks out, you can remove the shopping cart attribute from that session. And when the user logs out, you finally invalidate the session.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Ashish Malik
Ranch Hand

Joined: Jul 11, 2010
Posts: 50
Thats what i thought before...but shopping cart attribute may contain or most of the times will contain many other attribute like items purchased and their quantity.

Any way to implement that...

And i also dont want to trace for attribute for each item purchased and delete them one-by-one. Rather i want deactivate or invalidate something so that all item attribute would get invalidated.
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

You can create a class for your shopping cart and store it in the session.
Ashish Malik
Ranch Hand

Joined: Jul 11, 2010
Posts: 50
How to add items to shopping cart? And quantity of each?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56204
    
  13

Ashish Malik wrote:How to add items to shopping cart? And quantity of each?

At this point, this is just an object modeling exercise.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Session within session
 
Similar Threads
Must persist unpaid itineraries
shopping cart for FBN
Regarding refreshing a JSP page
Tag Library and Struts Framework
shopping cart or shopping memo?