[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Efficient Method to Show User's Last Viewed Catalog Items Function

Posted on 2009-04-09
4
Medium Priority
?
323 Views
Last Modified: 2012-05-06
Hi All,

I am looking to develop a shopping cart and I would like to include a user function which will show the user's last 2 product items viewed.

I am creating the cart using ASP.NET and SQL Server...

What would be an effective/lightweight way of storing this user specific information?

Would it be to write the product IDs to a cookie and call upon that cookie each time the page is loaded?

If anyone has implemented a similar function I would be very interested on how you achieved this.

Thanks,

Rit
0
Comment
Question by:rito1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
Buginator earned 2000 total points
ID: 24107644
Hi rito1,

For long term tracking, use cookies. This way the user can see this list a week after last visit.
For short term tracking, use sessions. In either case, remember to always check for null, otherwise nasty errors will show.

Both is lightweight if properly dealt with.

Since you are dealing with products that in theory could be deleted or edited after the user last visit, I would have saved the products ID as a CSV in the session/cookie. Then you lookup these products from the ID's, when you want to show the last visited product list. By doing this you avoid that the user visit your site, and click on a recently visited product, which has been deleted, and the user get an error.

By retrieving the products from the CSV, you end up with using a little bit more resources, but you also get up to date information about the product name, price, image, information and even if it still exist. The performance issue should not be a problem here, unless you have an extremely populated server. Even if that's the case, I would still use the above method, storing the product ID's in a CSV to avoid errors and confusion.

Let me know if there is anything else you wonder about.
0
 
LVL 1

Author Comment

by:rito1
ID: 24107679
Thank you for your opinion Buginator. Its much appreciated.

Kind Regards,

Rit
0
 
LVL 21

Expert Comment

by:Craig Wagner
ID: 24107724
If you want simple and lightweight, the cookie approach is probably your best bet.

If you wanted it to work in cases where the cookie was not enabled, you could use server-side session state to store the information. Out of the box ASP.NET uses in-process session state, so it's pretty fast to store and retrieve session information. The downside to this approach is that if the web server goes down you lose the session state, it's not persisted across sessions (e.g. if you wanted to show the information three days later when the user visits again), and if you're running in a web farm you'll either need to use sticky connections (so the user's session always returns to the same web server) or go with a central state server (e.g. the built-in state server), which will increase the complexity of deployment a tiny bit.
0
 
LVL 1

Author Comment

by:rito1
ID: 24107812
Thanks CraigWagner,

I like the idea of the user being able to return to the site a few days later and it store their last viewed info (providing their cookie remains).

Thanks Both,

Rit
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question