?
Solved

ASP.NET how to extend session time?

Posted on 2011-05-07
2
Medium Priority
?
603 Views
Last Modified: 2012-05-11
user logs in.  inside their control panel, they write up a bio.  when they click "Submit", they are bounced back to the login screen because they are no longer "logged in"

I'm using this code at the top of the control panel pages:
If Session("Auth") = False Then
            Response.Redirect("login-page.aspx")
        End If
        Name = Session("Name")
        UserID = Session("UserID")
        Auth = Session("Auth")

So, what happens is, they are taking too long writing up their bio and are bouncing out.  How do I extend the session to 30 minutes, or even an hour?
0
Comment
Question by:arthurh88
2 Comments
 

Expert Comment

by:zgamer99
ID: 35714279
This a server-side setting. You can edit the web.config and adjust as shown below:
<system.web>
        <sessionState timeout="1800"/>

Otherwise you can go into IIS Manager configure it there as well.
0
 
LVL 11

Accepted Solution

by:
SAMIR BHOGAYTA earned 2000 total points
ID: 35714604
Create  one page in same application name it as SessionExtender.aspx
write below code on page load event of it

protected void Page_Load(object sender, EventArgs e)
{

Session.Timeout = (!

string.IsNullOrEmpty(Request.QueryString["t"])) ? (Int16)Request.QueryString["t"] : 10;

// here we are passing time to extend values in query string if it is null it will take 10 min

Response.End();

}

Now open othe pages like home page.aspx etc where you would like to extend the session.

in body tag call below java script function

ExtendSession() some thing like this

<body onload="ExtendSession();">

</body>

In your head tag add below javascript

<script>
function ExtendSession()()
{
var img = new Image();
img.src="SessionExtender.aspx";   // or using query string t as img.src="SessionExtender.aspx?t=5";  
alert('called'); // make sure it is called after 3 second you can delete it. It is just for your refrence or **
}
function ExtendSession()
{
window.setInterval("ExtendSession()",3000);
}
</script>


or

in web.config file find <sessionState> node:



<sessionState

mode="InProc"

stateConnectionString="tcpip=127.0.0.1:42424"

sqlConnectionString="data source=127.0.0.1;user id=sa;password="

cookieless="false"

timeout="20"

/>

default is 20 - change it
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question