• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 559
  • Last Modified:

session Expired

In my application does not use  session variables, and we set it as timout is 60 min in web.config file, eventhough it doesnot consider web.config settings, so my requirement is my page should not expire at anycost user keep the page ,  pls give me the sample solution for resolve this issue.
0
Jeyakumar_mcp
Asked:
Jeyakumar_mcp
  • 4
  • 3
2 Solutions
 
abelCommented:
you say: you do not use session variables...
you say: you have a session timeout
you say: you do not consider web.config...

the session is always there, whether you want it or not. But you don't have to use it. The web.config is always there, without it your pages will not run, the settings are being considered.

The session timeout will fire, but why care? You don't use sessions, you say. So the session timeout is irrelevant.
0
 
Tony McCreathTechnical SEO ConsultantCommented:
Often you want to stop a session timing out while a user still has a page open on the website.

One way to do this is have some javascript that pings the website on a timer. This way the javascript will keep refreshing the rolling session timeout.
0
 
Jeyakumar_mcpAuthor Commented:
Please give me some sample code for using timer control
0
Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

 
abelCommented:
>  so my requirement is my page should not expire at anycost user keep the page ,

why not simply set the Session timeout to (almost) indefinite. That should do the trick quite well, don't you think? Microsoft has this to say:

"The Timeout property cannot be set to a value  greater than 525,600 minutes (1 year). The default value is 20 minutes."
-- Abel --
0
 
Tony McCreathTechnical SEO ConsultantCommented:
Having large session timeouts means all session data for all sessions will stay in memory for a long time. This may not be a good thing.

The javascript method will only keep the sessions alive while a user still has there browser open to the website.

This seems like a good ASP.Net articles on using javascript to stop timeouts

http://www.codeproject.com/KB/session/Reconnect.aspx

Here's some basic javascript timer code


<SCRIPT Language="Javascript">
function TimerCallback()
{
  window.alert("It's Time!");
  setTimeout('TimerCallback()', 5000); /* repeat the timer */
}
setTimeout('TimerCallback()', 5000); /* initial timer */
</SCRIPT>

Open in new window

0
 
abelCommented:
I agree to that reading. But what if you want to keep the session even if the user closes the browser? But that's another story (answer: use a session state server would make things easier).

On a similar note, you can try this (quite beautiful imo) solution as well. It follows, however, the same line of thought as Tiggerito's solution, so if you like it, don't forget to give him his part of the credits ;-) . Here: http://www.codeproject.com/KB/aspnet/SessionForever.aspx


0
 
Tony McCreathTechnical SEO ConsultantCommented:
Sessions are normally tracked by cookies in the browser. Once the browser is closed it is not possible to re-establish a session.

However, the server has no way of knowing if a browser is closed or just idle, hence the concept of rolling session timeouts.

abel,

As you say, your article reference seems to be a variant on the same theme as the one I found. I like the embeded image idea.
0
 
abelCommented:
@TheLearnedOne: I don't agree to deletion, this question received excellent coverage. Question was "how to prevent timeout of session". Both http:#24223480 (indefinite session, by abel) and http:#24223760 (client side refresh timer, by Tiggerito) provide answers. Both are needed to prevent the timeout from happening.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now