Solved

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

Posted on 2009-04-09
4
287 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now