Solved

Cookie limitations?

Posted on 2001-07-26
8
282 Views
Last Modified: 2011-09-20
I have a form page with a possible 35 items that can be ordered. On submission an asp page writes the values of the form entries to cookies. This seems to be limited to 18 or so, so i had to build in some javascript telling the customer that his shopping cart is full when he reaches 18 items and preventing him from entering more than that, since everything over 18 (sometimes 20?) seems to overwrite one of the other entries.

Does anyone know of a way around this limitation?  

This is the code that creates the cookies:

  For Each item In Request.Form
        If item <> "submit" And item <> "clear" Then
         If Request.Form(item) <> "" Then
            Response.Cookies(item) = Request.Form(item)
         End If
      End If
   Next
0
Comment
Question by:moonmoth
8 Comments
 
LVL 2

Expert Comment

by:DirkVe
ID: 6321813
How big is each value that you store into the cookies. Maybe you can reduce this size.
0
 
LVL 1

Expert Comment

by:yitz99
ID: 6321846
1. try using 'keys' - store each item as a key within one cookie

 For Each item In Request.Form
       If item <> "submit" And item <> "clear" Then
        If Request.Form(shopping_cart)(item) <> "" Then
           Response.Cookies(shopping_cart)(item) = Request.Form(item)
        End If
     End If
  Next

syntax:
Response.Cookies(cookie)[(key)|.attribute] = value

2. create one cookie with a long text like this:
item1=34~item2=83~item3=21...
you can then use the split function to parse out the values.
0
 
LVL 2

Accepted Solution

by:
DirkVe earned 75 total points
ID: 6321920
I think the 1st solution for yitz99 should do the work.

Good one, didn't think about that.


Some tip: I always store the shopping basket into the database into a temporary table. As key you can use the sessionID or even the userID when a user is logged on. The advantage of the userID is that you're shopping basket is saved and doesn't get lost when the session expires or when the user closed his browser by mistake. But of course, this is an improvement to your problem and NOT the solution you asked, so points should go to yitz99.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:moonmoth
ID: 6321946
DirkVe,

example of cookie: sch999 (max length is 5 characters) making it shorter is not an option

Yitz99,

could you comment a bit on that split function? I need it to work with the following code:

For Each item In Request.Cookies
      If Left(item,3) = "sch" Then
         itemId = Mid(item,4)
         quantity = Request.Cookies(item)
           strSQLOrderDetails="INSERT INTO schOOL_BESTELLING " _
            &"(item_nr,bestel_nr,aantal) VALUES(" _
            & itemId & "," & thisOrderNumber & "," & quantity & ")"
         con.Execute strSQLOrderDetails
         Response.Cookies(item).Expires = Now()-1000
      End If
   Next

Thanx
0
 

Author Comment

by:moonmoth
ID: 6321957
DirkVe,

example of cookie: sch999 (max length is 5 characters) making it shorter is not an option

Yitz99,

could you comment a bit on that split function? I need it to work with the following code:

For Each item In Request.Cookies
      If Left(item,3) = "sch" Then
         itemId = Mid(item,4)
         quantity = Request.Cookies(item)
           strSQLOrderDetails="INSERT INTO schOOL_BESTELLING " _
            &"(item_nr,bestel_nr,aantal) VALUES(" _
            & itemId & "," & thisOrderNumber & "," & quantity & ")"
         con.Execute strSQLOrderDetails
         Response.Cookies(item).Expires = Now()-1000
      End If
   Next

Thanx
0
 

Author Comment

by:moonmoth
ID: 6322334
Yitz,

just the syntaxis will do

thanks

Dirk,

You are right, this is probably a better way to do it. But i'm trying to leave as much as i can client-side, so if cookies can do the trick i'll do it with cookies. The entire site will already be built from database-content (SQLserver 7) in a way that once it is finished, anyone with the proper acces can change the content/look of the pages through form-pages, no html-knowledge acquiered.

If i can't get the cookie-bit to work i'll go for your solution and you get the points ;)
0
 
LVL 33

Expert Comment

by:hongjun
ID: 8623329
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
[split b/w DirkVe and yitz99]

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

hongjun
EE Cleanup Volunteer
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 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

20 Experts available now in Live!

Get 1:1 Help Now