Best practices for cookies in classic ASP - memory usage

M

MartyN

When using cookies in classic asp, is it safe to assume that using a
comma delimited list of values in one cookie is much more efficient
than using multiple cookies? (example below)

Response.Cookies("someCookie") = "101,102,103,104,105,106"
If InStr(Request.Cookies("someCookie"),"103") > 0 Then.......

vs.

Response.Cookies("101") = "True"
Response.Cookies("102") = "True"
Response.Cookies("103") = "True"
Response.Cookies("104") = "True"
Response.Cookies("105") = "True"
Response.Cookies("106") = "True"
If Request.Cookies("103") = "True" Then.....


Thank you!
 
A

Anthony Jones

MartyN said:
When using cookies in classic asp, is it safe to assume that using a
comma delimited list of values in one cookie is much more efficient
than using multiple cookies? (example below)

Response.Cookies("someCookie") = "101,102,103,104,105,106"
If InStr(Request.Cookies("someCookie"),"103") > 0 Then.......

vs.

Response.Cookies("101") = "True"
Response.Cookies("102") = "True"
Response.Cookies("103") = "True"
Response.Cookies("104") = "True"
Response.Cookies("105") = "True"
Response.Cookies("106") = "True"
If Request.Cookies("103") = "True" Then.....


Thank you!

The former is more effecient than the latter. Whether it is 'much' more
effecient depends on the real world usage but creating multiple cookies will
increase the size the requests being made to the server.
 
E

Egbert Nierop \(MVP for IIS\)

Anthony Jones said:
The former is more effecient than the latter. Whether it is 'much' more
effecient depends on the real world usage but creating multiple cookies
will
increase the size the requests being made to the server.

Hi!

In fact, each separate cookie is just one line in the HTML document as a
pre-content HTML-header. This is defined in RFC's and does not cost a lot
more resources or CPU.
It does not do a separate Server request (HTTP)
HOwever, since ASP is a script language, theoretically a Request.Cookies
statement is slower than a single Request.Cookies statement which can be
splitted into an array.
I would just choose the most convenient way of programming!

The most performance scalability is gotten by desiging good SQL scripts and
commands.
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top