Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Dec 6th, 2007, 9:29 AM   #1
ktsirig
Programmer
 
Join Date: Oct 2005
Posts: 54
Rep Power: 3 ktsirig is on a distinguished road
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...
ktsirig is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Intermittent crunching of the cookies grumpy Community Announcements and Feedback 5 Nov 5th, 2007 10:04 PM
Cookies or Sessions? Satans_Banjo PHP 2 Jul 9th, 2007 5:25 AM
FireFox Turning of cookies kruptof Coder's Corner Lounge 4 Aug 11th, 2006 9:13 PM
Delete local cookies with javascript Lich JavaScript and Client-Side Browser Scripting 9 Mar 18th, 2006 8:38 AM
Cookies sephers PHP 2 Jun 9th, 2005 11:08 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:33 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC