Missing data in cookie

W

Wally

I have a record set (rs) that contains 25 barcodes values that I set to true
in a cookie. (see code section below)

If I read the cookie from within the same page that created it, I see all
25 values. But if I redirect to another page and read the cookie only 18 of
the values remain.

Even though I load the same 25 barcodes at login, the 18 that remain can
differ each time.

If anyone can help figure out why I am missing data in the cookie, I would
appreciated it. The cookie size is only 2k.

Here is the section of code i am using to create the cookie. Hopefully, I
did not make any typos when I retyped it.

while not rs.eof
response.cookies(cstr(rs("code"))) = "true"
response.cookies(cstr(rs("code"))).expires = dateadd("d",1,date)
rs movenext
wend

Here is the section of code i am using to view the cookie.

for each cookie in Request.cookies
if not request.cookies(cookie).haskeys then
response.write "<br>"
response.write cookie + " = " + request.cookies(cookie)
else
for each key in request.cookies(cookie)
response.write "<br>"
response.write cookie + "( "+ key + ") = " +
request.cookies(cookie)(key)
next
end if
next
 
A

Aaron [SQL Server MVP]

Here is the section of code i am using to create the cookie. Hopefully, I
did not make any typos when I retyped it.

Are your Ctrl, C or V keys broken?
while not rs.eof
response.cookies(cstr(rs("code"))) = "true"
response.cookies(cstr(rs("code"))).expires = dateadd("d",1,date)
rs movenext
wend

Here is the section of code i am using to view the cookie.

for each cookie in Request.cookies
if not request.cookies(cookie).haskeys then
response.write "<br>"
response.write cookie + " = " + request.cookies(cookie)
else
for each key in request.cookies(cookie)
response.write "<br>"
response.write cookie + "( "+ key + ") = " +
request.cookies(cookie)(key)
next
end if
next

I will try this tomorrow when I'm on a PC but it looks like it should work.
In other words, on casual inspection, I can't see why 7 of the codes would
randomly disappear.

A
 
J

Jason Brown [MSFT]

when you say the data is only 2k, are you also taking into account the
cookies keys (names) and the expires date?

anyway, I'd recommend you keep the amount of data in the coookie to an
absolute minimum and use an alternative, say Session variables, or persisted
data in a DB, or application/session-scope FreeThreadedDomDocuments if you
want to persist bigger chunks of data


--
Jason Brown
Microsoft GTSC, IIS

This posting is provided "AS IS" with no warranties, and confers no
rights.
 
W

Wally

Using windows explorer the cookie file size shows as 2k.

This is existing code that I have inherited. I have suggested using session
variables to my client, but this would require code changes in 30 or more asp
pages and he wants me to spend a little more time trying to find this bug.
 
D

Dave Anderson

Wally said:
I have a record set (rs) that contains 25 barcodes values that I set
to true in a cookie. (see code section below)

If I read the cookie from within the same page that created it, I
see all 25 values. But if I redirect to another page and read the
cookie only 18 of the values remain.

Even though I load the same 25 barcodes at login, the 18 that remain
can differ each time.

Have you confirmed this with any other browser, or just with IE?



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top