Solved

Cookie limitations?

Posted on 2001-07-26
8
284 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

803 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