设置不同的超时在ASP.Net不同的会话变量 [英] Set different timeout for different session variables in ASP.Net

查看:196
本文介绍了设置不同的超时在ASP.Net不同的会话变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是可以设置为不同的会话超时不同在ASP.Net?

Is this possible to set different timeout for different session in ASP.Net?

编辑
我的意思是,在同一页面我有2个会话变量会话[SS1]和Session [SS2],在那里可以设置超时时间为每个会话?或者是有反正做同样喜欢保存会话cookie,并设置到期?
Sry基因即时通讯只是新的ASP.Net

Edited I mean that in the same page i have 2 session variable Session["ss1"] and Session["ss2"], is there possible to set timeout for each session? Or is there anyway to do the same like save session to cookie and set expire? Sry im just new to ASP.Net

推荐答案

我写了一个非常简单的扩展类,做到这一点。你可以找到源头code 这里

I wrote a very simple extender class that does that. You can find the source code here

用法:

//store and expire after 5 minutes
Session.AddWithTimeout("key", "value", TimeSpan.FromMinutes(5));

//get the stored value
Session.GetWithTimeout("key");

这篇关于设置不同的超时在ASP.Net不同的会话变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆