Click here to Skip to main content
15,947,411 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want To set unlimited session timeout for my website, but its getting expired in 6 Minutes.

On Next Page Load Event (After Sucessfull Login) I have Added this code,does this code affects session to expire before

HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoServerCaching();
HttpContext.Current.Response.Cache.SetNoStore();

What I have tried:

1. Changing Web.config Session Timeout Variable.
Posted
Updated 19-Oct-16 1:11am

You can't set an unlimited session timeout, but you can set a really high number here:

XML
<system.web>
    <sessionState timeout="60000" />
</system.web>
 
Share this answer
 
If you want people to be logged in for a long time (even indefinitely) then don't use the Session to show someone is logged in, use cookies instead.
 
Share this answer
 
Comments
mateen@123 18-Oct-16 10:26am    
Can You Post Link of any Example According To my Requirement
F-ES Sitecore 18-Oct-16 10:38am    
You'll need to re-write how your authentication works. The best thing is to use existing frameworks like asp.net Membership, or Identity, rather than trying to develop your own.
What John says is true, but...be aware that some systems ignore requests to lengthen the Session timeout because each Session takes server resources, and they cost money. If your session has already been reduced from the default 20 minutes to 6, you are likely to find that your request is ignored.
The longer you set your timeout, the more resources you will use - and do bear in mind that users do not often log out or otherwise signal that they are leaving your site.

Instead, I'd suggest that you might be better off using Cookies which are stored at the client end instead of the Session at all.
 
Share this answer
 
Are you using cookie based authentication or Token based authentication ?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900