473,804 Members | 3,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem storing data in a cookie...

Hi

I have an HTML search page that contains a drop-down box with
approximately 78,000 items in it.

The actual content of this select box varies depending upon some of the
parameters a user has chosen, so this needs to be loaded (possibly
several times as they change their parameters) and I've got this
working using AJAX.

However, as you can well imagine, this takes quite some time to get
this data from the database and turn into the select box.

To cut down time, I've put this in the Session("xxx") object held on
the server and this manages to cut it down from 15 seconds to 10
seconds. This tells me that it simply takes quite a lot of time to
transfer this data around the internet.

So...what I'd REALLY like to do is to save it to a cookie. Now, I've
found several examples on the web of how to write and read from cookies
but unfortunately it's not working in my hands. I suspect that it's
something to do with the value for the cookie...

The value would be something like this ("...." implies multiple lines).

value = "Please select a product code &nbsp;nbsp;<sel ect
name=""x""><opt ion
value=""y"">y"</option>.....</select>&nbsp;&n bsp;78,000produ cts
available".

Any ideas/suggestions would be most appreciated

Griff

Jun 13 '06 #1
2 1331

Just to provide some more info....

The JavaScript function that updates the web page AND *attempts* to set
the cookie's value is as follows:

function xmlHttpChange()
{
if (XmlHttp.readyS tate==4)
{
// Load the response text into a local variable
productCodeData = XmlHttp.respons eText;

// Update the web page with this data

document.getEle mentById('Produ ctCodeSelection ').innerHTML=pr oductCodeData;

// Save to cookie (e.g. "myAppName_Acme _1234")
var cookieName = "myAppName_ " + document.getEle mentById

('accountName') .value + "_" +
document.getEle mentById('userI D').value;

document.cookie = cookieName+"="+ escape(productC odeData);

XmlHttp=null;
}
}

When I check whether anything is held in the cookies, I put in the
following alert:

alert("document .cookie.length = " + document.cookie .length);

This returns ""document.cook ie.length = 0"

Something's not quite right here....

Griff

Jun 13 '06 #2
Hi,

Griff wrote:
Hi

I have an HTML search page that contains a drop-down box with
approximately 78,000 items in it.

The actual content of this select box varies depending upon some of the
parameters a user has chosen, so this needs to be loaded (possibly
several times as they change their parameters) and I've got this
working using AJAX.

However, as you can well imagine, this takes quite some time to get
this data from the database and turn into the select box.

To cut down time, I've put this in the Session("xxx") object held on
the server and this manages to cut it down from 15 seconds to 10
seconds. This tells me that it simply takes quite a lot of time to
transfer this data around the internet.

So...what I'd REALLY like to do is to save it to a cookie. Now, I've
found several examples on the web of how to write and read from cookies
but unfortunately it's not working in my hands. I suspect that it's
something to do with the value for the cookie...

The value would be something like this ("...." implies multiple lines).

value = "Please select a product code &nbsp;nbsp;<sel ect
name=""x""><opt ion
value=""y"">y"</option>.....</select>&nbsp;&n bsp;78,000produ cts
available".

Any ideas/suggestions would be most appreciated

Griff


It might be due to the size. A cookie can contain maximum 4KB, IIRC. I
am not sure what the behaviour is if you try to store a longer string.

I posted my CCookie object on my website, it's an abstraction of the
cookie API which allows you to call methods instead of manipulating the
cookie string. It also has methods allowing to check if session cookies
and/or permanent cookies are enabled. The code is self-documented.

http://www.galasoft-lb.ch/myjavascri...kie/index.html

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jun 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
3975
by: ndsoumah | last post by:
hello guys I'm trying to get access to variables I put in a session variable from another page and it fails... here's the exact situation main file page1.php
1
2138
by: Blossom | last post by:
Hi there, I have a problem with storing my Cookies. I made a servlet in which I store a Cookie (in the doGet()-method) to detect whether a user has already visited my webpage. I used the following code: Cookie c = new Cookie("sessionID", generateSessionID()); c.setMaxAge(60*60*24*365);
7
2148
by: Christoph Pieper | last post by:
Hi, we've the following problem : We have an asp-application which sets the cookie on first login. The cookie will never be touched during user access. The user can work the whole day, but after 6 to 7 hours, the cookie get 2-4 new asp-sessionid's thus overwriting the very first entries in the cookie. Does anyone had the same problem or has a solution. The server is a w2003 enterprise the client has windows xp sp2.
8
1657
by: Phoenix | last post by:
Here's a challenge that is killing me: I've got 2 web servers and a SQL Server and about 5,000 'users' who stay connected to the site all day. I have a page that is supposed to be 'real-time', so to do this, I have a 1px frame that refreshes every 15 seconds (so the other frame doesn't have to reload all the time--the top only reloads when a new record or a changed record hits the db). The real time data can be filtered in about 8...
7
2922
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the database into classes, which are used throughout the application. I have made class collections which, upon reading from the DB, create an instance of the class and store the DB values in there temporarily. My problem is that if user1 looks at...
7
1887
by: Mike | last post by:
I have developed an application, for psyc patients.... they type in very personal information in a web form to help them work through problems in their lives. Once they enter the info, I encrypt the data and store it in a MySQL database. Users can then print, edit, delete or share the information they entered with their therapist. I'm not happy storing this in the database for two reasons: (1) my host places restrictions on my database...
3
4436
by: Milsnips | last post by:
Hi there, i had a small project where i used a session to store the shopping cart, but if it times out, the user loses the cart. Then i thought instead of using session, i'll store the cart in a cookie, but cookie only stores string values, which makes it tricky to update/remove cart item values because i'd have to so substring, split, etc... What i'm thinking now is to store the cart in a database table, and just add a cookie with...
2
2009
by: Mythran | last post by:
We followed an example found on MSDN to create an encrypted FormsAuthenticationTicket and storing the ticket in a cookie. Is this the "correct" way to store the authentication ticket? We are attempting to create a web service from the web application and our goal is to have the user login to the web application and then, using the same credentials and/or authentication objects, access the web services to retrieve our data from other...
1
1309
by: mercea | last post by:
Hi guys, I am taking a column from a table and comparing each row in that table with a similar column in a gridview row by row. For each identical answer, grade increments by 1. after all the rows have been iterated through, the final grade is placed in another table. This worked for a while till i inserted in cookie variables for the updating it now works on and off. have any ideas what could be causing that? sometimes it increments the grade...
0
9705
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9575
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10564
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10320
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10073
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9134
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7609
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5645
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.