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

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

问题描述

它看起来像JavaScript没有访问身份验证Cookie(ASP.NET_SessionId','.ASPXFORMSAUTH')

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

在HTTP标头,我可以看到cookies,但的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天全站免登陆