Web Timers

  • Thread starter Thread starter Girish Pal Singh
  • Start date Start date
G

Girish Pal Singh

I want if a user is browsing the site for some time say 30 minutes
then the current his session should end data should be posted back,
how could i do it.
?
 
Girish,

You'll have to do that with client side javascript.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
You could create a method that

1. Checks for the existence of a Session "TimeStarted" variable
a. If it doesn't exist, create it and place the Current Time in it
2. Checks the Current Time against the Session variable
3. If the interval of difference is greater than your alloted time, take
some action.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.
 
Forgot to mention. Of course, the method I described would be placed in
every Page that the user might visit, and execute in the Page_Load method.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Neither a follower nor a lender be.
 
I am not quite sure why would you want to post the data.
The data can be incomplete or user was not going to submit his data at all.

If you just want to prevent his session from an expiration then there is a
simple method.

1. Create transparent.gif image 1x1 pixel.
2. create SessionRefresh.aspx page which outputs back to the browser that
image.
3. On the page which might take more than 20 minutes to fill out ( or any
page you want )
put following code somewhere.

<img src="transparent.gif" width=1 height=1 name="sessionrefresh">
<script>
window.setInterval("document.images['sessionrefresh'].src=sessionrefresh.asp
x;", 10*1000*60 );
</script>

So basically JavaScript will request every 10 minutes the
sessionrefresh.aspx and thus preventing session from expiration.

Also note that cashing might be a problem but you can always add ?param=time
in javascript to the end of sessionrefreshh.aspx. To prevent cashing.


George.
 
Back
Top