如果cookie被禁用,asp.net存储cookie作为会话cookie,而不是? [英] if cookies are disabled, does asp.net store the cookie as a session cookie instead or not?

查看:242
本文介绍了如果cookie被禁用,asp.net存储cookie作为会话cookie,而不是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,如果cookeis在客户端上禁用,我想知道是否...

basically, if cookeis are disabled on the client, im wondering if this...

dim newCookie = New HttpCookie("cookieName", "cookieValue")

newCookie.Expires = DateTime.Now.AddDays(1)

response.cookies.add(newCookie)

注意我设置了一个日期,所以它应该存储在磁盘上,如果cookie被禁用asp.net自动存储这个cookie为会话cookie(这是一个cookie,持续在浏览器内存中,直到用户关闭浏览器,如果我没有错误)....或者asp.net不添加cookie在任何地方(在任何地方)在这种情况下,我会有重新添加cookie到没有日期(作为会话cookie存储)的集合...当然,这将需要我添加一个cookie两次...也许第二次不必要的,如果它被存储在浏览器内存反正... im只是试图不存储它两次,因为它只是坏的代码!任何想法,如果我需要写另一行或不? (这将是)...

notice i set a date, so it should be stored on disk, if cookies are disabled does asp.net automatically store this cookie as a session cookie (which is a cookie that lasts in browser memory until the user closes the browser, if i am not mistaken).... OR does asp.net not add the cookie at all (anywhere) in which case i would have to re-add the cookie to the collection without the date (which stores as a session cookie)... of course, this would require me doing the addition of a cookie twice... perhaps the second time unnecessarily if it is being stored in browsers memory anyway... im just trying not to store it twice as it's just bad code!! any ideas if i need to write another line or not? (which would be)...

response.cookies.add(新的HttpCookie(cookieName,cookieValue)会话cookie在客户端浏览器内存

response.cookies.add(New HttpCookie("cookieName", "cookieValue") ' session cookie in client browser memory

感谢各人

推荐答案

MSDN 文章似乎表明没有内置的机制用于补偿用户禁用cookies。它还表明,如果没有启用某些级别的cookie,会话状态不工作。

This MSDN article seems to indicate that there is no built in mechanism for compensating with the user disabling cookies. It also indicates that session state does not work without at least some level of cookies being enabled.

我认为有一个机制,传递一个查询变量为会话ID,但略过文章(很快)我没有看到这个。

I thought that there was a mechanism for passing a query variable for the session id but skimming the article (quickly) I did not see this.

希望有帮助。

:它说,你可以使用cookieless会话(我想你可以)。他们使用一个单独的机制来嵌入会话ID的页面和URL链接。

It does say that you can use cookieless sessions (I thought you could). They use a separate mechanism to embed session ID in the pages and url links.

这篇关于如果cookie被禁用,asp.net存储cookie作为会话cookie,而不是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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