Solved

Cookie limitations?

Posted on 2001-07-26
8
283 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

896 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

16 Experts available now in Live!

Get 1:1 Help Now