Solved

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

Posted on 2009-04-09
4
313 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 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

739 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