Solved

Cookie limitations?

Posted on 2001-07-26
8
286 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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