![]() |
cookies for eshop basket
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... |
| All times are GMT -5. The time now is 3:44 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC