本文介绍了如何以编程方式获取会话cookie的名字吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有关会话ID在ASP.NET默认的Cookie名称为 ASP.NET_SessionId
。它也有可能这个名称更改为别的东西,比如<的sessionState cookieName =FooBar的/>
。
The default cookie name for the Session Id in ASP.NET is ASP.NET_SessionId
. It's also possible to change this name to something else like <sessionState cookieName="FooBar" />
.
有一个成员可以方便地访问这样的名字以 FormsAuthentication.FormsCookieName
?
Is there a member to easily access this name like with FormsAuthentication.FormsCookieName
?
推荐答案
考虑到,你说你在web.config中的cookie设置一个不同的名字,那么我会说,你可以从那里读取cookie名
Taking into account that you say that you set an different name for the cookie on the web.config then I'd say you could read the cookie name from there
SessionStateSection sessionStateSection =
(System.Web.Configuration.SessionStateSection)
ConfigurationManager.GetSection("system.web/sessionState");
string cookieName = sessionStateSection.CookieName;
这篇关于如何以编程方式获取会话cookie的名字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!