Solved

Cookie limitations?

Posted on 2001-07-26
8
288 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

623 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