C#/Session State Timeout
I am developing asp.net WebApplication. And my client wants that application never logout itself. When he click logout then only app should be logout. So, I set timeout to 525600 which means 1 year. Like this:
<compilation debug="true" targetFramework="4.0" />
Now, when i tested it on my local computer it works fine and never logout. But when i published it on server it is not working. It is logging out after 10 min approx.
Even I changed in CPanel asp.net settings to the same. Still it is not working.
Help me if u have any idea about it.
ANSWER: Hi there,
That's a very big mistake that consumes your RAM very quickly. The reason of 10 min. limit is IIS idle timeout. IIS automatically shuts down applications which stay idle for a period of time to clean up RAM.
to learn how to change this setting.
HOWEVER this is completely wrong approach as I said at first. The algorithm of infinite login should be created by using cookies. When a user logs in, create a hash string and save it in your database and also as a cookie which the expiration date is set to a very big value. When user opens your website, where-ever you check user login, firstly check the hash from cookie. If it exists in database set that user as logged-in without asking credentials.
Hope that helps,
---------- FOLLOW-UP ----------
Thanx for help.
Yes, This is a good option. But there is a query. I have not checked on server but if user close browser directly (without logout) or user pc shutdown unexpectedly (for any reason) at that time I want to clear cookies. So, next time when user start application it should ask for login. Because if i close browser and start it again then it will directly fetch data from cookie.
I hope it is possible.
"When he click logout then only app should be logout."
This was your only condition to logout that's why I advised you using cookies. If you want him to stay logged in only for that session without time limit, you have to go with the option 1 that I told you, setting IIS idle timeout to a big value.
Hope that helps,