如何检查从JavaScript如果加载页面有ASP.NET身份验证cookie? [英] how to check from JavaScript if loaded page has ASP.NET authentication cookie?

查看:87
本文介绍了如何检查从JavaScript如果加载页面有ASP.NET身份验证cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来JavaScript无法访问http头中的身份验证Cookie('ASP.NET_SessionId','.ASPXFORMSAUTH')

It looks like JavaScript does not have access to authentication cookies ('ASP.NET_SessionId', '.ASPXFORMSAUTH')

document.cookie对象没有它们。

in the http headers I can see cookies but document.cookie object does not have them.

推荐答案

ASP.NET会话cookie是仅限HTTP(默认情况下)(合理的话)。如果你需要知道用户是否在Javascript中验证,在页面上放置一个HiddenField,并根据你的验证令牌将其值设置为0或1是一个更好的解决方案。

ASP.NET session cookies are HTTP-only by default (and rightfully so). If you need to find out if the user is authenticated in Javascript, putting a HiddenField on the page and setting its value to 0 or 1 based on your authentication token is a much better solution.

这篇关于如何检查从JavaScript如果加载页面有ASP.NET身份验证cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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