473,387 Members | 1,365 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,387 software developers and data experts.

infinite session timeout



hi,

I have a web app with forms authentication and a timeout session of 20
mins for security reasons. I recently added a feature that allows users
(if they want to) to automatically log in (without entering username and
password) using the cookies. Now in this case the 20 mins session
timeout has no meaning anymore so I m thinking to make the timeout
infinite in this case only.

my question is, if i do this, and then a user used the application and
closed the browser , does the server knows that this session is no
longer needed and removes it from memory even if the timeout is infinite
?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #1
8 7279
why have any security if you do this?

"Joe Abou Jaoude" <an*******@devdex.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...


hi,

I have a web app with forms authentication and a timeout session of 20
mins for security reasons. I recently added a feature that allows users
(if they want to) to automatically log in (without entering username and
password) using the cookies. Now in this case the 20 mins session
timeout has no meaning anymore so I m thinking to make the timeout
infinite in this case only.

my question is, if i do this, and then a user used the application and
closed the browser , does the server knows that this session is no
longer needed and removes it from memory even if the timeout is infinite
?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #2
No, the server does not not about a user that has closed their browser and
will remain in memory. Worse yet, if you have a user that logs in then
closes their browser, then logs in again, you know will have two sessions on
your machine. You can see how this can quickly fill up your machine's RAM.

You should keep the timeout. You seem to want to have the user not log on
every time they come to your site. I am assuming you are using forms
authentication?

With forms authentication you have a login page defined. On the page_load
for the login page, you should just check for the cookie, validate the user,
set up their information(?), then redirect them to the page they were trying
to hit. Basically you have the btnLogin_Click code, also in the page_load
that processes the cookie.

It will be somewhat transparent for your users when their session does
timeout.

Would this solution work for you?

bill
"Joe Abou Jaoude" <an*******@devdex.com> wrote in message
news:%2******************@TK2MSFTNGP15.phx.gbl...


hi,

I have a web app with forms authentication and a timeout session of 20
mins for security reasons. I recently added a feature that allows users
(if they want to) to automatically log in (without entering username and
password) using the cookies. Now in this case the 20 mins session
timeout has no meaning anymore so I m thinking to make the timeout
infinite in this case only.

my question is, if i do this, and then a user used the application and
closed the browser , does the server knows that this session is no
longer needed and removes it from memory even if the timeout is infinite
?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #3
Hi Joe,

The browser in now way signals the server when it is closed. You can
implement functionality in one of the client-side DHTML event
(onbeforeunload), to signal the web server (via a web service or
standard web request).

I don't quite understand your original statement, however, about the
session timeout having no meaning now that the user doesn't have to log
in. Session and Authentication cookies are two separate things. If
session expires while the user is still "authenticated", a new session
will automatically be created for them. If you want to keep that
session around for as long as they are actively using the site, you
might consider implementing some functionality in the browser to "ping"
the web server. Every request will restart the session timeout (as long
as it is a sliding timeout), but if a user may sit on one page for a
long time, you could consider using the setTimeout JScript method to
call a method every so often that calls a web service or fire a simple
page request in the background - both of which have the effect of
keeping the timeout from expiring.

Obviously there are many details I've glossed over, but I hope this
helps.

Aidan

Nov 19 '05 #4
Hi Joe,

The browser in now way signals the server when it is closed. You can
implement functionality in one of the client-side DHTML event
(onbeforeunload), to signal the web server (via a web service or
standard web request).

I don't quite understand your original statement, however, about the
session timeout having no meaning now that the user doesn't have to log
in. Session and Authentication cookies are two separate things. If
session expires while the user is still "authenticated", a new session
will automatically be created for them. If you want to keep that
session around for as long as they are actively using the site, you
might consider implementing some functionality in the browser to "ping"
the web server. Every request will restart the session timeout (as long
as it is a sliding timeout), but if a user may sit on one page for a
long time, you could consider using the setTimeout JScript method to
call a method every so often that calls a web service or fire a simple
page request in the background - both of which have the effect of
keeping the timeout from expiring.

Obviously there are many details I've glossed over, but I hope this
helps.

Aidan

Nov 19 '05 #5
Hi Joe,

The browser in now way signals the server when it is closed. You can
implement functionality in one of the client-side DHTML event
(onbeforeunload), to signal the web server (via a web service or
standard web request).

I don't quite understand your original statement, however, about the
session timeout having no meaning now that the user doesn't have to log
in. Session and Authentication cookies are two separate things. If
session expires while the user is still "authenticated", a new session
will automatically be created for them. If you want to keep that
session around for as long as they are actively using the site, you
might consider implementing some functionality in the browser to "ping"
the web server. Every request will restart the session timeout (as long
as it is a sliding timeout), but if a user may sit on one page for a
long time, you could consider using the setTimeout JScript method to
call a method every so often that calls a web service or fire a simple
page request in the background - both of which have the effect of
keeping the timeout from expiring.

Obviously there are many details I've glossed over, but I hope this
helps.

Aidan

Nov 19 '05 #6


thank u all, so it's obvious that infinite session timeout is a very
very bad idea, and well the scenario explained by William F. Robertson
is exactly the scenario that i was affraid of.

a question for Aidan Marcuss:
i thought that the session timeout is always sliding. isn't that right ?
and if no how can i do that?

it seems that i wasn't very clear in my explanation before:

1- I m using form validation (username and passwords are in a database)

2- I use sessions not only to keep track of the user but also to save
info and variables required for the web app.
and the session timeout was 20 mins
and all was fine.

Now the client wanted to add a feature where the user can login
automatically (if he wants to).

so:
1- i used cookies to recognise users and the automatic login was
accomplished succesfully.

2- originaly the session timeout was designed for security reasons (at
least this is what i think), i.e if a user forgot the browser open the
session timeout will disallow another person to enter the site from the
browser.

3-this session timeout is no longer needed since anyone can logon
automatically to the site if a user cookie resides in the client
computer.

4- the sessions are used to save sql statements and other variables, and
the timeout session will reset those variables and all the work of the
user will be lost, this is why I was thinking to have infinite timeout
session

5- Finally, based on the replies, i think the better solution is to make
the session timeout longer for user authenticated automatically ( an
hour, a day...) but not to use an infinite timeout.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #7
Joe,

I am not sure how involved you want to get with this, but here is a possible
solution for you.

You could easily declare a couple static methods called.

public static void SaveUserInformation( string key, object data );
public static object GetUserInformation( string key );

These methods will satisfy the requirements for number 4.

When the SaveUserInformation(...) is called, you could look determine if the
user has the "auto logon cookie". If they do not have the autologin cookie,
you will save the information in Session through the
System.Web.HttpContext.Current.Session property. If they are one of the
"auto logon" people, you could save this information in Application. Here
is some psuedo code.

public static void SaveUserInformation( string key, object data )
{
if ( PersistUserData() )
{
System.Web.HttpContext.Current.Application.Lock();
System.Web.HttpContext.Current.Application["Auto_" + key] = data;
System.Web.HttpContext.Current.Application.UnLock( );
}
else
{
System.Web.HttpContext.Current.Session["Auto_" + key] = data;
}
}

The Application.Lock() method doesn't scale very well so you might want to
look towards you own static (or singleton) object to handle all the user
information (req 4).

The GetUserInformation(...) would just be the inverse of this operation.
The code will appear seamless to the page developer as it doesn't matter
whether the information is stored in session or persisted in Application.

HTH,

bill

"Joe Abou Jaoude" <an*******@devdex.com> wrote in message
news:uA*************@TK2MSFTNGP14.phx.gbl...


thank u all, so it's obvious that infinite session timeout is a very
very bad idea, and well the scenario explained by William F. Robertson
is exactly the scenario that i was affraid of.

a question for Aidan Marcuss:
i thought that the session timeout is always sliding. isn't that right ?
and if no how can i do that?

it seems that i wasn't very clear in my explanation before:

1- I m using form validation (username and passwords are in a database)

2- I use sessions not only to keep track of the user but also to save
info and variables required for the web app.
and the session timeout was 20 mins
and all was fine.

Now the client wanted to add a feature where the user can login
automatically (if he wants to).

so:
1- i used cookies to recognise users and the automatic login was
accomplished succesfully.

2- originaly the session timeout was designed for security reasons (at
least this is what i think), i.e if a user forgot the browser open the
session timeout will disallow another person to enter the site from the
browser.

3-this session timeout is no longer needed since anyone can logon
automatically to the site if a user cookie resides in the client
computer.

4- the sessions are used to save sql statements and other variables, and
the timeout session will reset those variables and all the work of the
user will be lost, this is why I was thinking to have infinite timeout
session

5- Finally, based on the replies, i think the better solution is to make
the session timeout longer for user authenticated automatically ( an
hour, a day...) but not to use an infinite timeout.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #8


ok, saving in application instead of session is a good idea. It might be
a good work around for the problem however it could have some memory
drawback.I'll have to look at it closely. thx.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #9

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

Similar topics

12
by: Geigho | last post by:
Setting session timeout in web.config file does not seem to have any effect. Any explanation or suggestion will be appreciated.
4
by: DavidS | last post by:
First: There are several ways to confuse one regarding session timeout. (1) web.config - <sessionState timeout="20"> (2) IIS Manager | Internet Information Services | ServerNode | Default Web Site...
3
by: jensen bredal | last post by:
Hello, This should probably very basic but it still gives me headeachs ;) I have my app where user log ind and some pages doauto refresh. i do not want the session to timeout. How can i do...
17
by: jensen bredal | last post by:
Hello, i'm struggling with a somehow badly understood session scenario. I provide acces to my pages based on form authentication using Session cookies. Som of my pages are supposed to be...
4
by: UJ | last post by:
I have a page where the user can upload a video file. As you can guess, this may take a while. Is there a way I can change the session timeout for just this one page? I would also want to change...
1
by: jitendgandhi | last post by:
Dear sir, i have folloing question relateded to asp. how can i get infinite session timeout? Jiten
25
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
I tried: <sessionState timeout="1"> </sessionState> bounced IIS, and after 1 minute still had a session. ??? -- thanks - dave
1
by: ritz16 | last post by:
In my appplication my client requires an infinite session timeout.Suppose i give sessionState mode="InProc" timeout="1440" and forms authentication timeout in web.config of 1440 (in minutes).Then...
2
by: Doogie | last post by:
Hi, We have a page we want to refresh every 30 minutes so that users can get up to date info. The problem is that there is information within the session that we need in each refresh to determine...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.