473,323 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Problem with Sessions / Cookies

Hi,

I believe I have a website (I didn't do the original coding) which uses
JavaScript/ASP to generate cookies.

It's a shopping cart application called UCart I believe.

The technologies involved are:

ASP
JavaScript
IIS
Microsoft Access

Im transferring this to a new host but am finding a problem with
Cookies. On the previous host, it was solved by them configuring the
server to place the website into a "lower contention session pool".

Has anyone heard of this, or can they offer any ideas as to how this
might be effected programmatically, or what a suggested alternative
might be.

To be honest Im having trouble figuring this mess out and how its all
called.

Thanks
Simon
Here is a snippet of code.

Im having trouble understanding the correlation between JavaScript and
ASP and although the code appears to be within <SCRIPT
LANGUAGE=JavaScript RUNAT=Server NAME="UC_CART"tags,I gather that it
using Sessions on the server through ASP.

What's happening is that in the process, two Session Id's are being
generated.

// Each of these is an array. Each array index corresponds to a line item.
// As such, each array should always be exactly the same length.
this.AssertCartValid(colNames, "Cart Initialization: ");
if (Session(this.Name) != null) {
this.SC = Session(this.Name).SC;
} else {
this.SC = new Array(this.numCols);
for (var i = 0; i < this.numCols; i++) this.SC[i] = new Array();

// Since the cart doesn't exist in session, check for cookie
from previous session
if (this.bStoreCookie){
cookieName = this.GetCookieName();
cookieStr = Request.Cookies(cookieName);
if (cookieStr != null && String(cookieStr) != "undefined"
&& cookieStr != "")
this.PopulateFromCookie(cookieStr);
}
// Create a reference in the Session, pass the whole object
(methods are not copied)
this.persist();
}

function SetCookie(){
var cookieName = this.GetCookieName()
var cookieStr = this.GetContentsSerial(this.cookieColDel,
this.cookieRowDel)
var cookieExp = GetCookieExp(this.cookieLifetime)
Response.Cookies(cookieName) = cookieStr
Response.Cookies(cookieName).expires = cookieExp
}

function UCpersist() {
Session(this.Name) = this;
if (this.bStoreCookie) this.SetCookie();
}
Dec 28 '07 #1
3 2325
"Simon Dean" <sj****@simtext.plus.comwrote in message
news:5t*************@mid.individual.net...
Hi,

I believe I have a website (I didn't do the original coding) which uses
JavaScript/ASP to generate cookies.

It's a shopping cart application called UCart I believe.

The technologies involved are:

ASP
JavaScript
IIS
Microsoft Access

Im transferring this to a new host but am finding a problem with
Cookies. On the previous host, it was solved by them configuring the
server to place the website into a "lower contention session pool".

Has anyone heard of this, or can they offer any ideas as to how this
might be effected programmatically, or what a suggested alternative
might be.

To be honest Im having trouble figuring this mess out and how its all
called.

Thanks
Simon
Here is a snippet of code.
<snip />

The problem is here:-
if (Session(this.Name) != null) {
this.SC = Session(this.Name).SC;
} else {
this.SC = new Array(this.numCols);
and here:-
>function UCpersist() {
Session(this.Name) = this;
if (this.bStoreCookie) this.SetCookie();
}
The code is storing an object in the Session. When this happens an
affiliation is created between the current thread and the session. ASP
Requests for this session must now always be run on the affiliated thread.
This creates 'contention' when two or more requests arrive which require the
same thread. Despite there being other worker threads available and CPU
capacity only one of requests can be processed and the others have to queue.
This hurts scalability and is generally discouraged.

You can help to reduce this (IMO poor design choice) by increasing the
AspProcessorThreadMax metabase property (default is 25). This property
defines the maximum size of the worker thread pool. Increasing this can
help spread the sessions across multiple threads thereby decreasing the
thread contention that results from session affiliation.

The downside is that potentially you end up with too many threads trying to
execute at once resulting in the cost of extra context switching. The
impact of the extra switching is probably a lot less than leaving requests
queued up that might otherwise begin processing.
--
Anthony Jones - MVP ASP/ASP.NET
Dec 29 '07 #2
Anthony Jones wrote:
"Simon Dean" <sj****@simtext.plus.comwrote in message
news:5t*************@mid.individual.net...
>Hi,

I believe I have a website (I didn't do the original coding) which uses
JavaScript/ASP to generate cookies.

It's a shopping cart application called UCart I believe.

The technologies involved are:

ASP
JavaScript
IIS
Microsoft Access

Im transferring this to a new host but am finding a problem with
Cookies. On the previous host, it was solved by them configuring the
server to place the website into a "lower contention session pool".

Has anyone heard of this, or can they offer any ideas as to how this
might be effected programmatically, or what a suggested alternative
might be.

To be honest Im having trouble figuring this mess out and how its all
called.

Thanks
Simon
Here is a snippet of code.

<snip />

The problem is here:-
> if (Session(this.Name) != null) {
this.SC = Session(this.Name).SC;
} else {
this.SC = new Array(this.numCols);

and here:-
>function UCpersist() {
Session(this.Name) = this;
if (this.bStoreCookie) this.SetCookie();
}

The code is storing an object in the Session. When this happens an
affiliation is created between the current thread and the session. ASP
Requests for this session must now always be run on the affiliated thread.
This creates 'contention' when two or more requests arrive which require the
same thread. Despite there being other worker threads available and CPU
capacity only one of requests can be processed and the others have to queue.
This hurts scalability and is generally discouraged.

You can help to reduce this (IMO poor design choice) by increasing the
AspProcessorThreadMax metabase property (default is 25). This property
defines the maximum size of the worker thread pool. Increasing this can
help spread the sessions across multiple threads thereby decreasing the
thread contention that results from session affiliation.

The downside is that potentially you end up with too many threads trying to
execute at once resulting in the cost of extra context switching. The
impact of the extra switching is probably a lot less than leaving requests
queued up that might otherwise begin processing.

Thanks for the reply Anthony.

Im not too familiar with ASP etc, but let me see if I get this straight.

I presume you access the same session from different threads providing
one of the threads has finished.

Im confused therefore, unless two Session requests are running
simultaneously.

If we can't make changes to the servers, what's the solution? Is it a
case of ripping through the code and basically restructuring all the
Session calls to be more sequential?

Cheers
Simon
Jan 1 '08 #3

"Simon Dean" <sj****@gmail.comwrote in message
news:5t*************@mid.individual.net...
Anthony Jones wrote:
"Simon Dean" <sj****@simtext.plus.comwrote in message
news:5t*************@mid.individual.net...
Hi,

I believe I have a website (I didn't do the original coding) which uses
JavaScript/ASP to generate cookies.

It's a shopping cart application called UCart I believe.

The technologies involved are:

ASP
JavaScript
IIS
Microsoft Access

Im transferring this to a new host but am finding a problem with
Cookies. On the previous host, it was solved by them configuring the
server to place the website into a "lower contention session pool".

Has anyone heard of this, or can they offer any ideas as to how this
might be effected programmatically, or what a suggested alternative
might be.

To be honest Im having trouble figuring this mess out and how its all
called.

Thanks
Simon
Here is a snippet of code.
<snip />

The problem is here:-
if (Session(this.Name) != null) {
this.SC = Session(this.Name).SC;
} else {
this.SC = new Array(this.numCols);
and here:-
function UCpersist() {
Session(this.Name) = this;
if (this.bStoreCookie) this.SetCookie();
}
The code is storing an object in the Session. When this happens an
affiliation is created between the current thread and the session. ASP
Requests for this session must now always be run on the affiliated
thread.
This creates 'contention' when two or more requests arrive which require
the
same thread. Despite there being other worker threads available and CPU
capacity only one of requests can be processed and the others have to
queue.
This hurts scalability and is generally discouraged.

You can help to reduce this (IMO poor design choice) by increasing the
AspProcessorThreadMax metabase property (default is 25). This property
defines the maximum size of the worker thread pool. Increasing this can
help spread the sessions across multiple threads thereby decreasing the
thread contention that results from session affiliation.

The downside is that potentially you end up with too many threads trying
to
execute at once resulting in the cost of extra context switching. The
impact of the extra switching is probably a lot less than leaving
requests
queued up that might otherwise begin processing.

Thanks for the reply Anthony.

Im not too familiar with ASP etc, but let me see if I get this straight.

I presume you access the same session from different threads providing
one of the threads has finished.
Normally, yes, when only simple primitive data like numbers, dates and
strings (or arrays of such) are stored in the session object. In that case
iwhich of the ASP worker threads processes a request will not matter, any
will do.

However when a session object has had a single threaded object stored in it,
it becomes affiliated with the worker thread and can only be processed by
that specific thread.
>
Im confused therefore, unless two Session requests are running
simultaneously.
That can't happen. The session object itself is single threaded and
therefore cannot be used by two threads simultaneously. Hence when there
are multiple outstanding requests from a single browser session for ASP
resources only one such request will be processed, the others will queue
(this is rare).

If we can't make changes to the servers, what's the solution? Is it a
case of ripping through the code and basically restructuring all the
Session calls to be more sequential?
It would be case of changing the code so that it no longer places objects in
the session object.

--
Anthony Jones - MVP ASP/ASP.NET
Jan 2 '08 #4

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

Similar topics

1
by: Spidah | last post by:
I am working on a shopping cart for a client and have struck a weird problem. The client's ssl setup is on a different url to the main site. As a result we get two copies of our shopping cart...
1
by: windandwaves | last post by:
Hi Gurus I am basically sorry that I have to bother you about this. I am a PHP beginner and I have been studying sessions and cookies over the last few weeks. I have learned lots, but I am...
6
by: JJ | last post by:
Hi, I really need to use cookieless ASP sessions with ASP 3 (IIS5) Can I find out the session ID from the first page, then post it or send it with the url to the next page, then at the start...
1
by: rushik | last post by:
Dear all, We have created a business portal for our organization. The technology used for that is LAMP. Our major access management system of the portal is based on cookies. we set some user...
2
by: rk325 | last post by:
I have a question about cookies & browser permissions and turning off cookies when creating a web site (cookieless mode in web.config). I have a web site that of course uses Session variables....
7
by: Atte André Jensen | last post by:
Hi I'm developing a site where I'd like to store information during a users visit. So far I've been using sessions, but as far as I can tell it's not possible to control for how long a session...
5
by: Beenz | last post by:
I am using cookies to keep track of users' sessions. If the cookie is disbaled or browser do not support cookies we show an appropriate page to the user saying that upgrade to such and such browser...
5
by: jheines | last post by:
I am trying to explain how cookies and sessions work in a class I teach, but I have hit a wall when it comes to the interaction between cookies and the state of the privacy settings in Internet...
8
by: Chuck Anderson | last post by:
I've instituted a sessions based scheme on my web site to combat hot linking to my images. When someone requests a page at my site, I set a session variable. I then use htaccess to redirect *all*...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.