locked
How to set a session to timeout in 15 minutes? RRS feed

  • Question

  • User-2079787324 posted

    Hi All,

    Can someone tell me how to set a page to expire after 15 minutes? and maybe auto redirect it to a session expire page.

    I tried the following on my web.config

      <system.web>
          <sessionState mode="InProc" timeout="1" />
        <httpRuntime executionTimeout="600" maxRequestLength="102400"/>
      
          <!--    <compilation debug="true"/> -->
        
        <authentication mode="Windows"/>
        
           
      </system.web>
      
    </configuration>

    and in globel.asax

    void Session_Start(object sender, EventArgs e)
    {
    // Code that runs when a new session is started
    Session.Timeout = 1;

    }

    I cant seems to get them to work

    Monday, May 12, 2014 4:26 AM

Answers

  • User-417640953 posted

    Hi roma_victa,

    Thank you post the issue to our forum.

    For setting the session timeout property, we should try to change other settings except web.config <sessionState>.

    Please follow below points.

    # Application Pool – Advanced Settings Menu – Process Model – Idle Time-out (minutes)

    # Sites – Session State – Cookie Settings – Time-out (minutes)

    # If you are using State Server or SQL Server to manage your session (instead of InProcess), Here is the steps to follow : 

       Sites – Session State – Session State Mode Settings – Time-out (seconds)

    # Under Web.configsystem.web – authentication mode – forms – timeout (for form authentication)

    Besides, please note that If you use InProc Session State mode, all session information can be lost at any time regardless

    of the timeout parameter if the application pool is recycled, which can happen at any time for different reasons.

    Hope that  helps, thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 13, 2014 5:12 AM
  • User724169276 posted

    if you change the IIS setting it will change for the entire webpages in the IIS right?

    I dont think so ... you can set session timout for a particular website also.

    1. Select Default Web Site (or your web site) > Properties > Home Directory > Application Settings > Configuration > Options.

    2. Enable the session state time-out and set the Session timeout for 60 minutes.

    3. Select Application Pools > DefaultAppPool > Properties.

    4. From the Performance tab under Idle timeout, set Shutdown worker processes after being idle for a value higher than 20.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 13, 2014 9:51 AM

All replies

  • User571301025 posted

    Hi,

    As per your code in web.config file your session will expired in 1 minute.

    I'am little bit confused your global.asax file code. What you want do with this?

    There is no need to set the timeout in session_start event.

    Hope this helps!

    Monday, May 12, 2014 4:38 AM
  • User-2079787324 posted

    i was just trying to do both ways . I set it to one for testing purpose but it still not working.

    any guss?

    Monday, May 12, 2014 6:18 AM
  • User1470285101 posted

    Your Web.config file should consists of the sessionState tag as shown in the below to make session timeout,

    <configuration>
    <system.web>
     <sessionState mode="InProc" timeout="60">
     </sessionState>
     </system.web>
    </configuration>

    Also,

    Refer the below article,to know how to set session timeout in different ways,

    http://www.aspdotnet-suresh.com/2010/10/session-timeout-problem-in-aspnet.html

    Hope this helps..!!!

    Monday, May 12, 2014 6:30 AM
  • User583282017 posted
    <sessionState mode="InProc" timeout="15">
    Monday, May 12, 2014 6:55 AM
  • User-2079787324 posted

    Did that but its not working

    Monday, May 12, 2014 7:25 AM
  • User-417640953 posted

    Hi roma_victa,

    Thank you post the issue to our forum.

    For setting the session timeout property, we should try to change other settings except web.config <sessionState>.

    Please follow below points.

    # Application Pool – Advanced Settings Menu – Process Model – Idle Time-out (minutes)

    # Sites – Session State – Cookie Settings – Time-out (minutes)

    # If you are using State Server or SQL Server to manage your session (instead of InProcess), Here is the steps to follow : 

       Sites – Session State – Session State Mode Settings – Time-out (seconds)

    # Under Web.configsystem.web – authentication mode – forms – timeout (for form authentication)

    Besides, please note that If you use InProc Session State mode, all session information can be lost at any time regardless

    of the timeout parameter if the application pool is recycled, which can happen at any time for different reasons.

    Hope that  helps, thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 13, 2014 5:12 AM
  • User-2079787324 posted

    Thank you Fuxiag for your detailed replay.

    I was wondering if there is a way to do in it the web page itself. The reason for this if you change the IIS setting it will change for the entire webpages in the IIS right?

    here i created a web site and added to a virtual folder. Is there any way to give time out facility to only to that virtual folder?

    Kind Regards

    Roma

    Tuesday, May 13, 2014 7:27 AM
  • User724169276 posted

    if you change the IIS setting it will change for the entire webpages in the IIS right?

    I dont think so ... you can set session timout for a particular website also.

    1. Select Default Web Site (or your web site) > Properties > Home Directory > Application Settings > Configuration > Options.

    2. Enable the session state time-out and set the Session timeout for 60 minutes.

    3. Select Application Pools > DefaultAppPool > Properties.

    4. From the Performance tab under Idle timeout, set Shutdown worker processes after being idle for a value higher than 20.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 13, 2014 9:51 AM