Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 1st, 2004, 10:49 AM
Authorized User
 
Join Date: Nov 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default Storing Problem!

I want to use a cookie in my project...suppose my visitor selects an item and added to the cart...now he/she continues shopping after adding one item...now he/she selects second item which he wants to buy and adds to the cart...but i want to add the products first in a cookie and then to database also for back up or vice versa...
The problem i m having is that how to add two items in a same cookie..my code follows..
<%
    pname=Request.Form("name")
    pdesc=Request.Form("pdesc")
    price=Request.Form("price")
    picture=Request.Form("picture")
    pieces=Request.Form("pieces")
    uid=session.sessionID

response.write(pieces)
response.write(pname)
response.write(pdesc)
response.write(price)
response.write(picture)
response.write(uid)

inserting in the cookie
response.cookies("cart")("name")=Request.Form("nam e")
response.cookies("cart")("price")=Request.Form("pr ice")
response.cookies("cart")("pdesc")=Request.Form("pd esc")
response.cookies("cart")("picture")=Request.Form(" picture")
response.cookies("cart")("pieces")=Request.Form("p ieces")

Response.write("inserted in the cookie")

for each cookiekey in request.cookies("cart")
response.write(cart) & " ."
response.write(cookiekey) & " ="
response.write(request.cookies("cart")(cookiekey))
next
%>

It only shows the last item added to the database or in cookie...the thing is it overwrites to the previous entries in the cookie....

Will anyone plz help me out in this..it will be highly appreciated!

Farzan Q.
BS(TeleCommunication)
Iqra University.
__________________
Farzan Q.
MS(TeleCommunication)
Mohammad Ali Jinnah University.
 
Old December 2nd, 2004, 01:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Farzan,

Thanks for your Personal Message.

You got to check if the cookie already has any value in it. If so use a COMMA as separator and append the next item to it. While retrieving you may split that using COMMA separator and process it.

Or if you could have another Cookie called ItemNumber, which would be incremented everytime the user tries to add another item to the cart, you may use the ItemNumber along with the cookie to store that in different cookie variables.

When the first Item is added, it may read as
Code:
response.cookies("cart")("name" & ItemNumber)=Request.Form("name")
response.cookies("cart")("price" & ItemNumber)=Request.Form("price")
response.cookies("cart")("pdesc" & ItemNumber)=Request.Form("pdesc")
response.cookies("cart")("picture" & ItemNumber)=Request.Form("picture")
response.cookies("cart")("pieces" & ItemNumber)=Request.Form("pieces")

Response.write("inserted in the cookie")

for each cookiekey in request.cookies("cart")
    response.write(cart) & " ."
    response.write(cookiekey) & " ="
    response.write(request.cookies("cart")(cookiekey))
next
You may try either options whichever you are comfortable with.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old December 2nd, 2004, 04:04 PM
Authorized User
 
Join Date: Nov 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey Mr. Vijay,

Thanx accepted. But i msgd you bcoz i really belv in ur skills. I was sure you will help me out using your xperience. You did it again :) Actually you helped me in my previous problems too. Really you your solutions worked for me!

Thanx once again for helping me. Atleast i got an idea after reading ur reply. i will try to do it with the ItemNumber. It seems to me that it will work....but i m not sure that will i be able to implement it successfully or not...i will be needing your help..

Thanx once again!

Farzan Q.
BS(TeleCommunication)
Iqra University.
 
Old December 5th, 2004, 10:18 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sure, you are always welcome to post here if you face any problem in proceeding with it.

We are here to help to the best we could.

Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
storing values paulg0702 Excel VBA 1 April 25th, 2007 11:33 PM
Problem While Storing image File kiran_p2p Java GUI 0 January 4th, 2007 11:41 PM
Storing a DataSet rit01 ASP.NET 1.x and 2.0 Application Design 0 October 23rd, 2006 04:04 PM
Storing Videos to Database... ankur_icfai SQL Server 2000 2 October 19th, 2006 01:18 AM
Storing hyperlink arnabghosh SQL Server 2000 1 November 24th, 2005 11:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.