第一种方式,修改forms的name

how to set the forms authentication cookie path

assume you have already solved this issue somehow, but since I stumbled upon this question I thought I should add my few cents.

To solve the issue use different cookie names in web.config. Something like:

<authentication mode="Forms">
<forms name=".ASPXFORMSAUTH_FOO"
loginUrl="public/login.aspx" cookieless="UseCookies" slidingExpiration="true"/>
</authentication>

and

<authentication mode="Forms">
<forms name=".ASPXFORMSAUTH_BAR"
loginUrl="public/login.aspx" cookieless="UseCookies" slidingExpiration="true"/>
</authentication>

第二种方式,修改forms的path,并且加上domain(必须添加)  (forms的name是保持一致的)

需要注意的是,监视cookie的时候,每一个页面的cookie是独立的,需要分别用F12查看。

The name of forms keep the same, they have different path,(although the domains are the same but must set it)
<authentication mode="Forms">
<forms loginUrl="CMSPages/LISA_logon.aspx" defaultUrl="Default.aspx" name=".ASPXFORMSAUTH" timeout="1440" slidingExpiration="true" domain="localhost" path="/LISA_50_Dev_CMSWeb" />
</authentication>

<authentication mode="Forms">
<forms loginUrl="CMSPages/logon.aspx" defaultUrl="Default.aspx" name=".ASPXFORMSAUTH" timeout="1440" slidingExpiration="true" domain="localhost" path="/LISA_60_Dev_CMSWeb"/>
</authentication>

第二个方法的问题,在于限定了domain name,如果限定为localhost的话,那么会导致使用域名无法登录的问题 。因为后台不识别了。

扩展

查看单个页面的cookie

相关文章

https://weblog.west-wind.com/posts/2008/Jan/20/Forms-Authentication-and-path-in-the-forms-Tag

https://docs.microsoft.com/en-us/aspnet/web-forms/overview/older-versions-security/introduction/forms-authentication-configuration-and-advanced-topics-cs

domain

When using cookie-based authentication tickets, this setting specifies the cookie's domain value.

The default value is an empty string, which causes the browser to use the domain from which it was issued (such as www.yourdomain.com).

In this case, the cookie will not be sent when making requests to subdomains, such as admin.yourdomain.com.

If you want the cookie to be passed to all subdomains you need to customize the domain attribute setting it to yourdomain.com.

path

When using cookie-based authentication tickets, this setting specifies the cookie's path attribute.

The path attribute enables a developer to limit the scope of a cookie to a particular directory hierarchy.

The default value is /, which informs the browser to send the authentication ticket cookie to any request made to the domain.

最新文章

  1. Kooboo CMS技术文档之三:切换数据存储方式
  2. 《Python操作SQLite3数据库》快速上手教程
  3. 分页控件layui的使用
  4. Windows 10 Build 14997中Edge浏览器已默认阻止Flash运行
  5. EditPlus 3.7 中文版已经发布
  6. POJ2942 Knights of the Round Table(点双连通分量 + 二分图染色)
  7. Frenetic Python实验(一)
  8. UVa 1586 Molar mass --- 水题
  9. C#中KeyDown和KeyPress区别
  10. javascript点击焦点图
  11. 生成Token字符串
  12. 提高C++编译速度-------pimpl 模式&amp; 桥接模式(转)
  13. Linux下的一些常用命令(一)
  14. 汇编实现: C库常见函数,串操作指令作用
  15. App设计模式纵横谈(1)
  16. Matlab中要显示数学公式或符号Latex
  17. php info
  18. C# Asp.net中xml串与对象互相转换
  19. Delphi 与 C/C++ 数据类型对照表
  20. 前端组件化Polymer入门教程(2)——Hello world

热门文章

  1. UDP网络程序实例
  2. Node.js概述
  3. GitHub代码托管平台搭建
  4. 汇总——WEB前端资源网
  5. =new、=null、.clear()、system.gc()的区别
  6. centos设置ssh安全只允许用户从指定的IP登陆
  7. JSON,对象..的数据格式
  8. pandas.DataFrame.rank
  9. 开发LED屏幕页面遇到的问题
  10. vue 微信授权解决方案