会议持续很长时间 [英] Session alive for long time
问题描述
我在许多站点中进行了搜索,但找不到适合我问题的正确解决方案.
问)如何使我的网站会话长时间保持活动状态,否则用户必须先手动注销才能退出我的网站.
我知道我们可以在托管服务器的web.config和iis中更改值.
但我不确定这是否好.
请提供更好的解决方案或示例代码.
谢谢,
chaitanya
Hi,
I searched in many sites but i could not find correct solution for my question.
Q)How to keep session of my site alive for a long time or user can not be kicked out of from my site until he do logout manually.
I know that we can change value in web.config and in iis at hosting server.
but i am not sure whether it is good or not.
please give a better solution or sample code.
Thanks,
chaitanya
推荐答案
您可以通过web.config在服务器上进行更改,但这是一个非常非常糟糕的主意.
You can change it at the server via web.config, but it is a very, very bad idea.
<configuration>
<system.web>
<sessionState timeout="20"></sessionState>
</system.web>
</configuration>
但是,这将占用服务器资源,直到会话结束为止,这可能会减少您可以支持的用户数量,或严重影响对用户的响应时间.
想想如果您将会话设置为持续到用户注销之前会发生什么情况.如果用户未注销但断开连接,会发生什么情况?资源仍然在服务器上被占用...
相反,请考虑使用Cookie代替会话变量-它们旨在保持持久性,而不是会话.
However, this will tie up server resources until the session ends, which may reduce the number of users you can support, or badly affect the response time to users.
Think what would happen if you do set the session so that it lasts until the user logs off. What would happen if the user doesn''t log off, but gets disconnected, say? The resources are still tied up at the server...
Instead, think about using cookies instead of session variables - they are intended to be persistent, which sessions aren''t.
这篇关于会议持续很长时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!