原文地址:http://www.c-sharpcorner.com/UploadFile/deepak.sharma00/using-cookie-less-session-in-Asp-Net/

How to Cookie-less Session

By default a session uses a cookie in the background. To enable a cookie-less session, we need to change some configuration in the Web.Config file. Follow these steps:

  1. Open Web.Config file
  2. Add a <sessionState> tag under <system.web> tag
  3. Add an attribute "cookieless" in the <sessionState> tag and set its value to "AutoDetect" like below:

    <sessionState cookieless="AutoDetect" regenerateExpiredSessionId="true"/>

The possible values for "cookieless" attribute are:

  • AutoDetect : Session uses background cookie if cookies are enabled. If cookies are disabled, then the URL is used to store session information.
  • UseCookie: Session always use background cookie. This is default.
  • UseDeviceProfile: Session uses background cookie if browser supports cookies else URL is used.
  • UseUri: Session always use URL.

"regenerateExpiredSessionId" is used to ensure that if a cookieless url is expired a new new url is created with a new session. And if the same cookieless url is being used by multiple users an the same time, they all get a new regenerated session url.

We have configured our "Web.config" file to enable cookieless session. Now, its time to test it.

Asp.Net 禁用cookie后使用session的更多相关文章

  1. IE禁用Cookie后的session处理

    IE禁用Cookie后解决方案:URL重写 购物车案例<IE禁用Cookie后> 购物界面ShowBook.servlet public void doGet(HttpServletReq ...

  2. 浏览器禁用Cookie后的Session处理

    1. 实现购物车, 可以基于Cookie, 也可以基于Session, 若服务器性能较差, 可以考虑基于Cookie实现购物车 2. 解决方案: URL重写 把用户可能点的每一个超链接后面,都跟上用户 ...

  3. php 会话控制(禁用cookie后session为什么会失效?)

    首先说明一点:session不一定必须依赖cookie,只是php默认客户端sessionid基于cookie方式保存. 到此,我想你也应该了解了php默认的session客户端保存方式是基于cook ...

  4. 浏览器禁用cookie后php如何保持session会话-use_trans_sid机制

    原文:浏览器禁用cookie后php如何保持session会话-use_trans_sid机制 为防止浏览器禁用cookie导致服务器会话无法保持,php开发了一个机制,该机制开启后,浏览器发起请求后 ...

  5. 关于PHP中浏览器禁止Cookie后,Session能使用吗?

    sessionid是存储在cookie中的,解决方案如下: Session URL重写,保证在客户端禁用或不支持COOKIE时,仍然可以使用Session session机制.session机制是一种 ...

  6. php在客户端禁用cookie时让session不失效的解决方法

    cookie固然好,不过有些客户端浏览器会禁用cookie,这就会导致你所依赖cookies的程序会失效或出错,那么若真出现用户关闭cookies的情况,PHP应该如何再次使用session?方法还是 ...

  7. 禁止COOKIE后对SESSION的影响

    一.理解SESSION机制 简单来说:每一个SESSION都有一个唯一的session_id , 默认情况下,session_id存储在客户端(默认COOKIE['PHPSESSID']), 在使用S ...

  8. 禁用cookie后

    服务器为某个访问者创建一个内存区域,这个就是所谓的session,这个区域的存在是有时间限制的,比如30分钟,这块区域诞生的时候,服务器会给这个区域分配一个钥匙,只有使用这个钥匙才能访问这个区域,这个 ...

  9. PHP--浏览器禁用cookie后,怎么使用session

    sessionid是存储在cookie中的,解决方案如下: Session URL重写,保证在客户端禁用或不支持COOKIE时,仍然可以使用Session session机制.session机制是一种 ...

随机推荐

  1. 浅谈C中的指针和数组(六)

    数组和指针,原本不想在写了,觉得这部分差不多了,但是自己在写程序的时候还是发现了一个错误.首先说一下我的要求: 给一个函数传递一个二维数组,然后我想在这个函数里面计算这个数组的行数. 写个类似的错误D ...

  2. Python进阶之模块与包

    模块 .note-content {font-family: "Helvetica Neue",Arial,"Hiragino Sans GB","S ...

  3. 深入A标签点击触发事件而不跳转的详解

    本文介绍下,当点击A标签时,触发事件但不跳转的实现方法,有需要的朋友参考下吧. 点击页面上的空链接,点击后页面自动刷新,并会定位到页面顶端. 不过,有时需要点击#页面但不作跳转,可以这样写: < ...

  4. Eclipse --Type /com.xx.app/gen already exists but is not a source folde解决方案

    两种解决方案: Two actions, first: 1.Right click on the project and go to "Properties" 2.Select & ...

  5. php分页类及其实现原理

    /** * * 实现思路:分页显示拆分 : 1...上页 12 13 14 15 [16] 17 18 19 20 ...100 下页 * * function htmlPart1() : 上页 * ...

  6. 服务端NETTY 客户端非NETTY处理粘包和拆包的问题

    之前为了调式和方便一直没有处理粘包的问题,今天专门花了时间来搞NETTY的粘包处理,要知道在高并发下,不处理粘包是不可能的,数据流的混乱会造成业务的崩溃什么的我就不说了.所以这个问题 在我心里一直是个 ...

  7. Ubuntu各种软件的安装

    普通的例如g++.deadbeef等源中有的软件,可以用apt-get安装 sudo apt-get install XXX 还有很多直接在software center搜索下载 对于下载来源代码需要 ...

  8. 翻译 GITHUB上HOW TO BE A GOOD PROGRAMMER

    转载请注明出处: http://www.cnblogs.com/hellocwh/p/5184072.html 更多内容点击查看 https://ahangchen.gitbooks.io/windy ...

  9. 运用JavaScript构建你的第一个Metro式应用程序(onWindows 8)(三)

    原文 http://blog.csdn.net/zhangxin09/article/details/6793593 这是<运用 JavaScript构建你的第一个Metro式应用程序>系 ...

  10. linux 查看信息命令

    # uname -a # 查看内核/操作系统/CPU信息# head -n 1 /etc/issue # 查看操作系统版本# cat /proc/cpuinfo # 查看CPU信息# hostname ...