sessions, which is the more efficient way

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.
 
L

Lucas Tam

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.
 
G

Grant Merwitz

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
 
L

Lucas Tam

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.
 

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,780
Messages
2,569,611
Members
45,278
Latest member
BuzzDefenderpro

Latest Threads

Top