Session timeout

Hi,

Where can I exactly set session timeout?  What is the difference in setting the timeout in web.config, global.asax or FormAuthenticationTicket etc.?

Is it possible to show remaining time for expiring session in pages?

ayha
LVL 7
ayha1999Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fizchCommented:
You would want to set the session timeout in the web.config file. Unfortunately, the only way to countdown the remaining time to expiration would be to build your own control. You know that everytime the page is sent, your expiration restarts. So however long you have to timeout set for, you would count back from there on page load.
0
daniel_ballaCommented:
> Is it possible to show remaining time for expiring session in pages?
that would always be the same, equal to the session timeout (as fizch stated it is counted from the last request onwards)
About setting it, you could set it in machine.config (therefore applied to ALL sites running on that server), then you can set it in web.config and you can also set it programatically using the TimeOut property of the HttpSessionState object (so something like Session.TimeOut = 19)
0
daniel_ballaCommented:
you could do a javascript counter that would start from the session timeout and show on page. that would give the user a fair estimation.
0
bsdotnetCommented:
simple Javascript:

<script language="JavaScript">
        var StartTime  = "";
        var varTimeout = 15;
        function Timer() {
            if(StartTime=="") StartTime = new Date().getTime();
            var newTime = new Date();
            newTime.setTime(60000 * varTimeout - newTime.getTime() + StartTime);
            if (document.all.expiryTime.value!="0:0")
                { document.all.expiryTime.value = newTime.getMinutes() + ":" + newTime.getSeconds(); }      
            setTimeout("Timer()", 1000);
        }
        setTimeout("Timer()", 1000);
</script>

<input type=text name="expiryTime" size=5>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.