Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,237 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,338 people online right now. Registration is fast and FREE... Join Now!




cookies for eshop basket

 
Reply to this topicStart new topic

cookies for eshop basket

ktsirig
6 Dec, 2007 - 07:34 AM
Post #1

D.I.C Head
**

Joined: 14 Sep, 2005
Posts: 71


My Contributions
Hello!

I want to create an eshop basket page for my website.

In the page of each product there is a button which when I press sets a cookie with the value of the respective product_id, using the following code:

<asp:Button ID="btbasket" runat="server" Text="Buy this product" />



In the code behind file, I have the following:

Protected Sub insert_cookie(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles btbasket.Click
Dim MyCookie As New HttpCookie("eshopCookie")
MyCookie.Value = MyCookie.Value & product_code
Response.Cookies.Add(MyCookie)
MyCookie.Expires = DateTime.Now.AddHours(12)
End Sub

Then, when the user wants to see all the things he/she has ordered, they visit the Basket.aspx page,

which has this:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim colCookies As New ArrayList()
For i As Integer = 0 To Request.Cookies.Count - 1
colCookies.Add(Request.Cookies(i))
Next

grdCookies.DataSource = colCookies
grdCookies.DataBind()
End Sub



and, in the .aspx file,

<asp:GridView
id="grdCookies"
Runat="server"/>

But my problem is that the gridview only shows 1 product_id, and, in particular, tha last product the user has selected a he browses the list of the available products...

Is there something else I must do to store all selected product_ids in the cookie and then retrieve them in Basket.aspx page? Must I use different cookie each time?

Thank you for your time...
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 06:14AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month