sessions, which is the more efficient way

  • Thread starter Thread starter Grant Merwitz
  • Start date Start date
G

Grant Merwitz

Hi

I currently have a web site that utilises sessions on a particular page.
When a user clicks a button on this page, a session is created for the
duration of the request, and then terminated straight afterwards.

The user could do this a handful of times per visit, and although the site
does not have heavy traffic currently, it needs to be scalable to do so in
the future.

Now which way is more efficient.

1) To create a session when the user logs on, and use that same session for
this particular request how ever many time it's called. And time the session
out after 20 minutes.

2) Or to create and terminate the session for the duration of the request as
i am currently doing

Any help would be appreciated. Also, if i'm not clear enough in this
explanation, please let me know, and i will try explain in more detail.
 
Now which way is more efficient.

1) To create a session when the user logs on, and use that same
session for this particular request how ever many time it's called.
And time the session out after 20 minutes.

2) Or to create and terminate the session for the duration of the
request as i am currently doing

Option 2 defeats the purchase of session variables. Session variables are
used to store data that needs to persist for a session not a single
request. If you wish to only use a variable for a single request, use
context variables instead (httpcontext.current.items).

Another possiblity is to use Viewstate - these variables are valid for a
single page.
 
I don't think i explained my problem properly hear.

I need to set this session to use another service on the same server. (which
is utilised during a single request on my aspx page)
This service requires this session to be set as a means of authentication.
Bear in mind, i have no control over this, i have to set a session.

So would it be better to set that session each time a user uses the method
that consumes this service

Or should i set the session for the duration of the Users visit
 
So would it be better to set that session each time a user uses the
method that consumes this service

Or should i set the session for the duration of the Users visit

I would just leave it set for the duration of the user's visit.
 
Back
Top